Commits

Brent Tubbs committed bd84725

fixing 'silk run'

Comments (0)

Files changed (3)

 
 setup(
     name='silk-deployment',
-    version='0.3.1',
+    version='0.3.2',
     author='Brent Tubbs',
     author_email='brent.tubbs@gmail.com',
 	packages=find_packages(),
     txt = sudo('ls -1 %s' % dirname)
     return txt.split('\r\n')
 
-def _is_live(site):
+def _is_supervisored(site):
     """Returns True if site 'site' has a supervisord.conf entry, else False."""
     # Check both the default include location and the silk <=0.2.9 location.
     old_conf_file = _join(SRV_ROOT, site, 'conf', 'supervisord.conf')
-    return exists(env.supd_conf_file) or exists(old_conf_file)
+    new_conf_file = _join('/etc/supervisor/conf.d', '%s.conf' % site)
+    return exists(new_conf_file) or exists(old_conf_file)
 
 def _socket_head_request(path):
     """Given a path to a socket, make an HTTP HEAD request on it"""
         # delete some.
         suspects = rollbacks[:-(env.rollback_cap + 1)]
         for folder in suspects:
-            fullpath = _join(SRV_ROOT, folder)
-            if not _is_live(fullpath):
+            if not _is_supervisored(folder):
+                fullpath = _join(SRV_ROOT, folder)
                 sudo('rm -rf %s' % fullpath)
 
     # Clean up old socket files in /tmp/ that have no associated site
 def get_gunicorn_cmd(site_env, bin_dir=''):
     """Given a copy of Fabric's state in site_env, configure and return the
     gunicorn cmd line needed to run the site"""
-    site_config = site_env.config
+    site_config = site_env['config']
     gconfig = copy.copy(GUNICORN_DEFAULTS)
     gconfig.update(site_config['gunicorn'])
 
     # Default to using a unix socket for nginx->gunicorn
-    default_bind = GUNICORN_BIND_PATTERN % site_env.deployment
+    if 'deployment' in site_env:
+        default_bind = GUNICORN_BIND_PATTERN % site_env.deployment
+        # Default to using the site name and timestamp in the procname
+        gconfig['name'] = site_env['deployment']
+    else:
+        default_bind = 'localhost:8000'
+        gconfig['name'] = site_config['site']
+
     gconfig['bind'] = gconfig.get('bind', default_bind)
 
-    # Default to using the site name and timestamp in the procname
-    gconfig['name'] = site_env.deployment 
 
     debug = gconfig.pop('debug', None)
     options = ' '.join(['--%s %s' % (x, y) for x, y in gconfig.iteritems()])
     # also mount the static dirs.
     root = os.environ['SILK_ROOT']
     role = os.environ['SILK_ROLE']
-    config = silk.lib.get_config(root, role)
+    config = app_container.get_config(root, role)
     config['wsgi_app'] = 'silk.devserver:app'
 
-    cmd = silk.lib.get_gunicorn_cmd(config)
+    cmd = get_gunicorn_cmd({'config': config})
 
     subproc_env = {
         'SILK_ROOT': root,
     }
 
     # By adding our current subproc_environment to that used for the subprocess, we
-    # ensure that the same paths will be used (such as those set by virtualsubproc_env)
+    # ensure that the same paths will be used (such as those set by virtualenv)
     subproc_env.update(os.environ)
 
     _run(cmd.split(), SIGINT, cwd=root, env=subproc_env)
             # Stick some information about the role and root into the current env,
             # then call the local function in cmd_map.
             os.environ['SILK_ROLE'] = app_container.get_role() or ''
-            os.environ['SILK_ROOT'] = silk.lib.get_root(os.getcwd()) or ''
+            os.environ['SILK_ROOT'] = app_container.get_site_root(os.getcwd()) or ''
             cmd_map[cmd]()
         else:
             # Use project-provided fabfile if present, else the one built into