env.project_name = 'kraken-ui'
-env.roledefs = {
- 'test': ['less.ly'],
- 'production': ['reportcard2.pmtpa.wmflabs'],
-}
+env.use_ssh_config = True # this is not working for me!
+env.colors = True
+
+
+# defaults
+
+# Hm.
+env.local_dist_directory = 'tmp/dist'
+env.dist_directory = 'dist'
+
+
+# There should be a way to do this using stages.
+# See: http://tav.espians.com/fabric-python-with-cleaner-api-and-parallel-deployment-support.html
+# env.config_file = False
+# env.stages = ['production', 'staging']
+
+# environments
+@task(alias='prod')
+def production():
+ """Set production environment variables"""
+ env.hosts = ['reportcard2.pmtpa.wmflabs']
+ env.directory = '/srv/reportcard/kraken-ui'
+ env.owner = 'www-data'
+ env.group = 'www'
+
+@task
+def staging():
+ """Set staging environment variables"""
+ env.hosts = ['less.ly']
+ env.directory = '/home/wmf/projects/kraken-ui'
+ env.user = 'wmf'
+ env.owner = 'wmf'
+ env.group = 'www'
@task
@task
def fix_permissions():
"""Recursively fixes permissions on the deployment host."""
+ sudo('chmod -R g+w %s')
+ sudo('chown -R %(owner)s:%(group)s %(directory)s' % env)
pass
@task
def update():
"""Runs git pull on the deployment host."""
- pass
+ with cd(env.directory):
+ run('git pull')
+
@task
def distribute():
"""Copies tmp/dist to deployment host."""
+ local("rsync -Caz -v %(local_dist_directory)s %(user)s@%(host)s:%(directory)s/%(dist_directory)s" % env)
+ # TODO: make sure the following works.
+ # rsync_project(local_dir=env.local_dist_directory, remote_dir="%(user)s@%(host)s:%(directory)s/%(dist_directory)s" % env)
pass
@task
def restart_server():
"""Restarts node.js server on the deployment host."""
+ # need to work on this for less.ly
+ sudo("supervisor restart reportcard")
pass
@task
def deploy():
"""Full deployment of latest project"""
- pass
\ No newline at end of file
+
+
+@task
+def test():
+ puts("user: %(user)s" % env)
+ run('whoami')
\ No newline at end of file