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 lighttpd config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsackett committed Jul 16, 2009
1 parent a9fef58 commit b9c2f7f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
33 changes: 33 additions & 0 deletions templates/conf/lighttpd.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$HTTP["host"] =~ {{url}} {

$HTTP["remoteip"] =~ "127.0.0.1" {
alias.url += (
"/doc/" => "/usr/share/doc/",
"/images/" => "/usr/share/images/"
)
$HTTP["url"] =~ "^/doc/|^/images/" {
dir-listing.activate = "enable"
}
}

alias.url += (
"/m/" => "/home/websites/lighttpd/{{project}}/site_media/",
)

$HTTP["url"] !~ "(/m/)" {
proxy.server = ("" =>
(( "host" => "127.0.0.1",
"port" => {{port}}
))
)
}

server.document-root = "/home/websites/lighttpd/{{project}}/site_media/"
compress.cache-dir = "/home/websites/lighttpd/{{project}}/cache/"
url.rewrite-once = (
"^/favicon.ico$" => "/m/im/favicon.ico",
"^/robots.txt$" => "/m/robots.txt",
)
server.errorlog = "/home/websites/lighttpd/{{project}}/logs/error.log"
accesslog.filename = "/home/websites/lighttpd/{{project}}/logs/access.log"
}
47 changes: 41 additions & 6 deletions weaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,63 @@ def init(args):
)

def build(args):
scripts(working_dir)
conf(working_dir)
load_settings()
scripts()
conf()

def load_settings(working_dir):
def load_settings():
working_dir = os.getcwd()
sys.path += [working_dir]
import settings

config.project = getattr(settings, 'PROJECT_HOME')
config.code = getattr(settings, 'CODE_HOME')

config.url = getattr(settings, 'SITE_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 = dict(
staging=config.port[0],
internal=config.port[1],
production=config.port[2]
)

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

template = env.get_template('scripts/setup_directories.sh.tmpl')
content = template.render(PROJECT=config.project)
file(os.path.join(working_dir, 'scripts', 'setup_directories.sh'), 'w').write(content)
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)
file(os.path.join(working_dir, 'scripts', 'setup_syslinks.sh'), 'w').write(content)
file(os.path.join('scripts', 'setup_syslinks.sh'), 'w').write(content)

def conf():
os.mkdir('conf')
os.mkdir(os.path.join('conf', 'staging'))
os.mkdir(os.path.join('conf', 'internal'))
os.mkdir(os.path.join('conf', 'production'))

template = env.get_template('conf/lighttpd.tmpl')
staging_content = template.render(project=config.project,
url=config.url['staging'],
port=config.port['staging'])
production_content = template.render(project=config.project,
url=config.url['production'],
port=config.port['production'])
internal_content = template.render(project=config.project,
url=config.url['internal'],
port=config.port['internal'])
filename = '99-%s.conf' % 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 Down

0 comments on commit b9c2f7f

Please sign in to comment.