first_deploy completes, supervisord runs (#174), but gunicorn isn't kicking off
authorBryan <btbonval@gmail.com>
Mon, 2 Dec 2013 23:58:30 +0000 (18:58 -0500)
committerBryan <btbonval@gmail.com>
Mon, 2 Dec 2013 23:58:30 +0000 (18:58 -0500)
confs/prod/supervisord-root.conf [deleted file]
fabfile.py
reqs/common.txt

diff --git a/confs/prod/supervisord-root.conf b/confs/prod/supervisord-root.conf
deleted file mode 100644 (file)
index e77ee30..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-[supervisord]
-logfile = /var/log/supervisord.log
-logfile_maxbytes = 10MB
-logfile_backups = 5
-loglevel = info
-pidfile = /var/run/supervisord.pid
-
-[supervisorctl]
-serverurl = unix:///var/run/supervisor.sock
-
-[unix_http_server]
-file = /var/run/supervisor.sock
-chmod = 0777
-
-[rpcinterface:supervisor]
-supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
-
-[program:gunicorn]
-command=/var/www/karmaworld/manage.py run_gunicorn -c confs/prod/gunicorn.conf
-autostart = true
-autorestart = true
-redirect_stderr = true
-stopsignal = QUIT
-
-[program:celeryd]
-command=/var/www/karmaworld/prod-code/manage.py celery worker --pidfile=/var/www/karmaworld/var/run/celeryd.pid -l info
-autorestart = true
-redirect_stderr = true
-stdout_logfile=/var/log/celeryd.log
-priority = 2
-stopsignal = QUIT
-
index 0b475be81691b6d900f31318d2b2719a821f84b9..01385adff043d5b6e3dbf756ca277b9dab243d5c 100644 (file)
@@ -5,7 +5,7 @@
 import os
 import ConfigParser
 
-from fabric.api import cd, env, lcd, prefix, run, task, local, settings
+from fabric.api import cd, env, lcd, prefix, run, sudo, task, local, settings
 from fabric.contrib import files
 
 ######### GLOBAL
@@ -16,7 +16,7 @@ env.repo_root = '~/karmaworld'
 env.proj_root = '/var/www/karmaworld'
 env.branch = 'prod'
 env.code_root = '{0}/{1}-code'.format(env.proj_root, env.branch)
-env.supervisor_conf = '{0}/confs/{1}/supervisord-root.conf'.format(env.code_root, env.branch)
+env.supervisor_conf = '{0}/confs/{1}/supervisord.conf'.format(env.code_root, env.branch)
 
 ######## Define host(s)
 def here():
@@ -219,22 +219,45 @@ def file_setup():
     Deploy expected files and directories from non-apt system services.
     """
     ini_parser = ConfigParser.SafeConfigParser()
-    ini_parser.read(env.supervisor_conf)
+    if not ini_parser.read(env.supervisor_conf):
+      raise Exception("Could not parse INI file {0}".format(env.supervisor_conf))
     for section, option in (('supervisord','logfile'),
                             ('supervisord','pidfile'),
                             ('unix_http_server','file'),
                             ('program:celeryd','stdout_logfile')):
       filepath = ini_parser.get(section, option)
       # generate file's directory structure if needed
-      run('mkdir -p {0}'.format(os.path.split(filepath))
+      run('mkdir -p {0}'.format(os.path.split(filepath)[0]))
+      # touch a file and change ownership if needed
+      if 'log' in option and not files.exists(filepath):
+          sudo('touch {0}'.format(filepath))
+          sudo('chown {0}:{1} {2}'.format(env.user, env.group, filepath))
+
+@task
+def check_secrets():
+    """
+    Ensure secret files exist for syncdb to run.
+    """
+
+    secrets_path = env.code_root + '/karmaworld/secret'
+    secrets_files = ('filepicker.py', 'static_s3.py', 'db_settings.py')
+
+    errors = []
+    for sfile in secrets_files:
+        ffile = os.path.sep.join((secrets_path,sfile))
+        if not files.exists(ffile):
+            errors.append('{0} missing. Please add and try again.'.format(ffile))
+    if errors:
+        raise Exception('\n'.join(errors))
 
 @task
 def first_deploy():
     """
     Sets up and deploys the project for the first time.
     """
-    file_setup()
     make_virtualenv()
+    file_setup()
+    check_secrets()
     update_reqs()
     syncdb()
     start_supervisord()
index 6339beaf1c19de50e88d23d31a6a95f441ee80fc..f3edab42534d9da44d46add9aff1091f575a90e8 100644 (file)
@@ -3,7 +3,6 @@ django-celery==3.0.21
 django-compressor==1.2
 Fabric==1.5.3
 South==0.7.6
-Sphinx==1.1.3
 supervisor==3.0b1
 oauth2client==1.0
 urllib3==1.5