Skip to content
Permalink
Browse files

"server-ize" the deploy env with supervisor/nginx

  • Loading branch information...
amontalenti committed Feb 21, 2013
1 parent e526f32 commit 9c842e030fb2b519c251826cd6cf1d0671183e8f
Showing with 29 additions and 18 deletions.
  1. +11 −0 deployment/nginx/sites-enabled/hacknode1
  2. +8 −0 deployment/supervisor/conf.d/hacknode1.conf
  3. +2 −0 dev-requirements.txt
  4. +8 −17 fabfile.py
  5. +0 −1 requirements.txt
@@ -0,0 +1,11 @@
server {
listen 80;
server_name hacknode1.alephpoint.com;
location / {
try_files $uri @hacknode1;
}
location @hacknode1 {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi-hacknode1.sock;
}
}
@@ -0,0 +1,8 @@
[program:hacknode1]
command=uwsgi --plugins=http,python -s /tmp/uwsgi-hacknode1.sock --file /home/shared/servers/hacknode1/app/app.py --callable app -H /home/shared/servers/hacknode1/rapid-env --chmod-socket 666
directory=/home/shared/servers/hacknode1/app
autostart=true
autorestart=true
stdout_logfile=/home/shared/logs/hacknode1.log
redirect_stderr=true
stopsignal=QUIT
@@ -3,3 +3,5 @@ livereload
# for ipython notebook
tornado
pyzmq
# for deployment
Fabric
@@ -4,47 +4,38 @@
env.use_ssh_config = True
env.hosts = ["shared@hacknode"]

def unique_id():
def sh(cmd):
return local(cmd, capture=True)
return "{}__{}".format(sh("whoami"), sh("hostname"))

@task
def print_my_id():
"""Print your unique identifier."""
puts("UNIQUE ID: " + unique_id())
TEAM_NAME = "hacknode1"

@task
def list_home():
"""List files in home directory."""
run("ls -lha")

@task
def list_deploys():
"""List deployment directories."""
run("ls deploys")
def list_servers():
"""List deployment servers."""
run("ls servers")

def virtualenv_run(cmd):
run("source rapid-env/bin/activate && {}".format(cmd))

@task
def setup_virtualenv():
"""Set up virtualenv on remote machine."""
with cd("deploys/" + unique_id()):
with cd("servers/" + TEAM_NAME):
run("virtualenv rapid-env")
virtualenv_run("pip install -r requirements.txt")

@task
def run_devserver():
"""Run the dev Flask server on remote machine."""
with cd("deploys/" + unique_id()):
with cd("servers/" + TEAM_NAME):
virtualenv_run("cd app && python app.py runserver --host=0.0.0.0 --port=8000")

@task
def deploy():
"""Deploy project remotely."""
run("mkdir -p deploys")
rsync_project(remote_dir="deploys/" + unique_id(),
run("mkdir -p servers")
rsync_project(remote_dir="servers/" + TEAM_NAME,
local_dir="./",
exclude=("*.pyc", ".git", "rapid-env", "steps", "activate"))

@@ -1,4 +1,3 @@
ipython
Flask
Flask-Script
Fabric

0 comments on commit 9c842e0

Please sign in to comment.
You can’t perform that action at this time.