Commits

Brent Tubbs  committed ce2c52c

ver 0.0.5

  • Participants
  • Parent commits 296ab3c

Comments (0)

Files changed (3)

 setup(
     name='silk-deployment',
     author='Brent Tubbs',
-    version='0.0.4',
+    version='0.0.5',
 	packages=find_packages(),
     package_dir={'silk': 'silk'},
     include_package_data=True,

File silk/cfg_templates/supervisord.conf

 user=nobody
 autostart=true
 autorestart=true
-stdout_logfile=%(site_root)s/logs/%(site)s.log
+stdout_logfile=%(site_root)s/logs/supervisor.log
 redirect_stderr=True
 environment=%(process_env)s

File silk/fabfile.py

 import datetime
 import pkg_resources
 import yaml
+import random
 
 def _get_silk_deps():
     silk_deps_file = pkg_resources.resource_filename('silk', 'deps.yaml')
 
 def _get_blame():
     """Writes a yaml file that contains the site config, plus some deployment info"""
+    comment = """#This file shows the deployed site's configuration for historical purposes.  
+#It is not read by the process."""
     blame = [
         {'deployed_by': env.user,
         'deployed_from': os.uname()[1],
-        'deployed_at': datetime.datetime.now()},
+        'deployed_at': datetime.datetime.now(),
+         'deployed_role': env.roles[0]},
         {'config':env.config}
     ]
-    #open file in local tmp dir and write it
-    return yaml.safe_dump(blame, default_flow_style=False)
-    #f = open('/tmp/blame.yaml', 'w')
-    #f.write(blame_str)
-    #f.close()
+    return '\n'.join([
+        comment, 
+        yaml.safe_dump(blame, default_flow_style=False)
+    ])
+
+def _write_blame():
+    #randomize the string to reduce chance of collision
+    blamefile = '/tmp/%s-blame.yaml' % ''.join([random.choice('abcdefghijklmnopqrstuvwxyz') for x in xrange(5)])
+    f = open(blamefile, 'w')
+    f.write(_get_blame())
+    f.close()
+    put(blamefile, '/'.join([env.workdir, 'blame.yaml']))
+    os.remove(blamefile)
 
 def reload():
     print "RELOADING CONFIGS"
             os.path.join(env.site_root, item['system_path'])
         )
     template_vars = {
-        'user': env.user,
-        'deployed_from': os.uname()[1],
         'cmd': silk.lib.get_gunicorn_cmd(env.config, bin_dir='%s/bin' % (env.envdir)),
         'nginx_static': nginx_static,
         'nginx_hosts': ' '.join(env.config['listen_hosts']),
     template_list = (
         ('supervisord.conf',os.path.join(config_dir, 'supervisord.conf')),
         ('nginx.conf',os.path.join(config_dir, 'nginx.conf')),
-        ('blame.txt',os.path.join(env.workdir, 'blame.txt')),
     )
     _write_templates(template_list, template_vars)
+    _write_blame()
 
 def switch():
     print "MOVING NEW CODE INTO PLACE"
 
 def blah():
     """dummy function for testing things"""
-    _get_blame()
+    print _get_blame()
 
 def hostname():
     """Used for testing"""