Commits

Anonymous committed 62cdc60

fixing silk push with no gunicorn.bind specified

Comments (0)

Files changed (5)

 
 setup(
     name='silk-deployment',
-    version='0.2.2',
+    version='0.2.3',
     author='Brent Tubbs',
     author_email='brent.tubbs@gmail.com',
 	packages=find_packages(),
         ],
     },
 	install_requires = [
+        'gunicorn',
         'CherryPy',
         'Fabric >= 0.9.2',
         'PyYAML',

silk/devserver.py

 root = silk.lib.get_site_root(os.getcwd())
 config = silk.lib.get_config(root, role)
 
-#mount the wsgi app
-wsgi_app = cherrypy.lib.attributes(config['wsgi_app'].replace(':', '.'))
-cherrypy.tree.graft(wsgi_app, '')
-
 if config['static_dirs']:
     for static_dir in config['static_dirs']:
         # Mount each of our static dirs as its own app in the cherrypy tree.
         sys_path = os.path.join(root, static_dir['system_path'])
         cherry_conf = {'/': {'tools.staticdir.on': True,
                              'tools.staticdir.dir': sys_path,}}
-        cherrypy.tree.mount(wsgi_app, script_name=url_path, config=cherry_conf)
+        cherrypy.tree.mount(None, script_name=url_path, config=cherry_conf)
+
+#mount the wsgi app
+wsgi_app = cherrypy.lib.attributes(config['wsgi_app'].replace(':', '.'))
+cherrypy.tree.graft(wsgi_app, '')
 
 sys.path.append(root)
 os.chdir(root)
     env.workdir = '/'.join(['/tmp', env.site])
     env.rollbackdir = '/'.join([SRV_ROOT, 'rollbacks'])
     env.deploytime = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
-    env.config['bind'] = env.config['gunicorn']['bind']
+    env.config['bind'] = env.config['gunicorn'].get('bind', 'unix:/tmp/%s.sock'
+                                                    % env.site)
     env.config['silk_deps'] = _get_silk_deps()
     env.config['site_deps'] = _get_site_deps(env.local_root)
 
 
 def get_gunicorn_cmd(site_config, bin_dir=''):
     gconfig = copy.copy(site_config['gunicorn'])
-    #default to using a unix socket for nginx->gunicorn
-    if 'bind' not in gconfig:
-        gconfig['bind'] = 'unix:/tmp/%s.sock' % site_config['site']
+
+    # Default to using a unix socket for nginx->gunicorn
+    gconfig['bind'] = gconfig.get('bind', 
+                                  'unix:/tmp/%s.sock' % site_config['site'])
+    
+    # Default to using the site name in the procname
+    gconfig['name'] = gconfig.get('name', site_config['site'])
+
     debug = gconfig.pop('debug', None)
     options = ' '.join(['--%s %s' % (x, y) for x, y in gconfig.iteritems()])
     if debug:
     
     cmd = silk.lib.get_gunicorn_cmd(config)
     
-    env = {
+    subproc_env = {
         'SILK_ROOT': root,
         'SILK_ROLE': silk.lib.get_role(),
     }
 
-    # By adding our current environment to that used for the subprocess, we
-    # ensure that the same paths will be used (such as those set by virtualenv)
-    env.update(os.environ)
+    # 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)
+    subproc_env.update(os.environ)
 
-    run_til_you_die(cmd.split(), SIGINT, cwd=root, env=env)
+    run_til_you_die(cmd.split(), SIGINT, cwd=root, env=subproc_env)
 
     # This 1 second sleep lets the gunicorn workers exit before we show the
     # prompt again.