Skip to content

Instantly share code, notes, and snippets.

@danielrichman
Created June 30, 2012 22:26
Show Gist options
  • Save danielrichman/3025813 to your computer and use it in GitHub Desktop.
Save danielrichman/3025813 to your computer and use it in GitHub Desktop.
habitat deployment misc
from habitat_calendar.cal import app as application
<uwsgi>
<chdir>/home/habitat</chdir>
<virtualenv>/home/habitat/ENV</virtualenv>
<wsgi-file>/home/habitat/wsgi/calendar.wsgi</wsgi-file>
<socket>/var/run/habitat-sockets/calendar</socket>
<chmod-socket>666</chmod-socket>
<master />
<vacuum />
<no-orphans />
<logto>/home/habitat/logs/calendar.wsgi</logto>
<processes>1</processes>
<pidfile>/home/habitat/logs/calendar.pid</pidfile>
</uwsgi>
@reboot ./launch habitat.parser.Parser ./habitat.yml
@reboot ./launch habitat_extensions.transition.spacenearus.SpaceNearUs ./habitat.yml
20 * * * * misc/couchdb_runviews.py http://localhost:5984 habitat > /dev/null
35 6 * * * /usr/sbin/logrotate -s logs/logrotate.state logs/logrotate.conf
#!/home/habitat/ENV/bin/python
import sys
import os
from habitat.utils.startup import main
from habitat.utils.dynamicloader import load
# From cusf-standalone-predictor
def detach_process():
# Fork
if os.fork() > 0:
os._exit(0)
# Detach
os.setsid()
null_fd = os.open(os.devnull, os.O_RDWR)
for s in [sys.stdin, sys.stdout, sys.stderr]:
os.dup2(null_fd, s.fileno())
# Fork
if os.fork() > 0:
os._exit(0)
if len(sys.argv) not in [2, 3]:
print "Usage: {0} <daemon name> [<config file>]".format(sys.argv[0])
sys.exit(1)
daemon = load(sys.argv.pop(1))
detach_process()
main(daemon)
compress
missingok
rotate 5
weekly
/home/habitat/logs/transition.wsgi {
postrotate
/bin/kill -HUP `cat /home/habitat/logs/transition.pid`
endscript
}
/home/habitat/logs/calendar.wsgi {
postrotate
/bin/kill -HUP `cat /home/habitat/logs/calendar.pid`
endscript
}
/home/habitat/logs/parser.log /home/habitat/logs/spacenearus.log {
}
from habitat_extensions.transition.app import app as application
<uwsgi>
<chdir>/home/habitat</chdir>
<virtualenv>/home/habitat/ENV</virtualenv>
<wsgi-file>/home/habitat/wsgi/transition.wsgi</wsgi-file>
<socket>/var/run/habitat-sockets/transition</socket>
<chmod-socket>666</chmod-socket>
<master />
<vacuum />
<no-orphans />
<logto>/home/habitat/logs/transition.wsgi</logto>
<processes>3</processes>
<pidfile>/home/habitat/logs/transition.pid</pidfile>
</uwsgi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment