Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
build now creates the apache file. i simplified settings.py.tmpl some…
Browse files Browse the repository at this point in the history
… to match what i do in deploys. i can always introduce more complexity later.
  • Loading branch information
jcsackett committed Jul 17, 2009
1 parent af1fdcd commit 99f87f6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 17 deletions.
13 changes: 4 additions & 9 deletions templates/settings.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ PROJECT_HOME = '' #the name of the directory the project will be hosted under
CODE_HOME = '' #the name of the directory the code will be hosted in

REPO_TYPE = '' #one of git, hg, or svn
REPO = ''
REPO = '' #the url of the code repo
USER = '' #The user for the server

#SERVER BASED SETUP INFO
# Each of the following variables consists of a three part tuple, defining
# that variable for each server in STAGING, INTERNAL, and PRODUCTION

LIGHTTPD_USER = ('', '', '') #The lighty user for the server (e.g. www-data)
APACHE_USER = ('', '', '') #The apache user for the server (e.g. www-data)
ADMIN = ('', '', '') #The admin email for the apache instance (e.g. [email protected])

MYSQL_USER = ('', '', '') #The mysql user for the project
MYSQL_PASSWORD = ('', '', '') #The password for the mysql user on the project

SERVER = ('', '', '') #The ip or servername for the server
USER = ('', '', '') #The user for the server
SITE_URL = ('', '', '') #The url the site is hosted at on the server (http://example.com, http://example.com:8080, http://bad.example.com)
APACHE_PORT = ('', '', '') #The port apache is listening on
URL = ('', '', '') #The url the site is hosted at on the server (http://example.com, http://example.com:8080, http://bad.example.com)
PORT = ('', '', '') #The port apache is listening on
DJANGO_PROCESS = ('', '', '') #The process daemon for the wsgi django handler
OWNER = ('', '', '') #The user who should own the site files, logs, etc
GROUP = ('', '', '') #The group who should own the site files, logs, etc

54 changes: 46 additions & 8 deletions weaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,44 @@ def load_settings():

config.project = getattr(settings, 'PROJECT_HOME')
config.code = getattr(settings, 'CODE_HOME')
config.user = getattr(settings, 'USER')
config.repo = getattr(settings, 'REPO')
config.repo_type = getattr(settings, 'REPO_TYPE')

config.url = getattr(settings, 'SITE_URL')
config.url = getattr(settings, 'URL')
config.url = dict(
staging='^%s$' % '\.'.join(config.url[0].split('.')),
internal='^%s$' % '\.'.join(config.url[1].split('.')),
production='^%s$' % '\.'.join(config.url[2].split('.')),
)
config.port = getattr(settings, 'APACHE_PORT')
config.port = getattr(settings, 'PORT')
config.port = dict(
staging=config.port[0],
internal=config.port[1],
production=config.port[2]
)
config.admin = getattr(settings, 'ADMIN')
config.admin = dict(
staging=config.admin[0],
internal=config.admin[1],
production=config.admin[2]
)
config.django_process = getattr(settings, 'DJANGO_PROCESS')
config.django_process = dict(
staging=config.django_process[0],
internal=config.django_process[1],
production=config.django_process[2]
)

def scripts():
os.mkdir('scripts')

template = env.get_template('scripts/setup_directories.sh.tmpl')
content = template.render(PROJECT=config.project)
content = template.render(project=config.project)
file(os.path.join('scripts', 'setup_directories.sh'), 'w').write(content)

template = env.get_template('scripts/setup_syslinks.sh.tmpl')
content = template.render(PROJECT=config.project, CODE=config.code)
content = template.render(project=config.project, code=config.code)
file(os.path.join('scripts', 'setup_syslinks.sh'), 'w').write(content)

def conf():
Expand All @@ -84,6 +99,28 @@ def conf():
file(os.path.join('conf', 'production', filename), 'w').write(production_content)
file(os.path.join('conf', 'internal', filename), 'w').write(internal_content)

template = env.get_template('conf/apache.tmpl')
staging_content = template.render(project=config.project,
port=config.port['staging'],
djangoprocess=config.django_process['staging'],
admin=config.admin['staging'],
code=config.code)
production_content = template.render(project=config.project,
port=config.port['production'],
djangoprocess=config.django_process['production'],
admin=config.admin['production'],
code=config.code)
internal_content = template.render(project=config.project,
port=config.port['internal'],
djangoprocess=config.django_process['internal'],
admin=config.admin['internal'],
code=config.code)
filename = '%s' % config.project
file(os.path.join('conf', 'staging', filename), 'w').write(staging_content)
file(os.path.join('conf', 'production', filename), 'w').write(production_content)
file(os.path.join('conf', 'internal', filename), 'w').write(internal_content)


commands = {
'init':init,
'build':build
Expand All @@ -93,7 +130,8 @@ def conf():
cmd = sys.argv[1]
args = sys.argv[2:]

try:
commands[cmd](args)
except KeyError:
print '%s is not a weaver command.' % cmd
c = commands.get(cmd, None)
if c is None:
print '%s is not a weaver command.' % cmd
else:
c(args)

0 comments on commit 99f87f6

Please sign in to comment.