fabfile.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import time
  2. from fabric.api import run, execute, env, cd
  3. """
  4. Manage auto-deploy webhooks remotely.
  5. Production hook:
  6. forever start -l $HOME/hookshot.log -a deploy/hookshot.js -p 4000 -b production -c "cd $HOME/production/current && git pull && bundle exec jekyll build >> $HOME/hookshot.log"
  7. forever restart deploy/hookshot.js -p 4000 -b production -c "cd $HOME/production/current && git pull && bundle exec jekyll build >> $HOME/hookshot.log"
  8. forever stop deploy/hookshot.js -p 4000 -b production -c "cd $HOME/production/current && git pull && bundle exec jekyll build >> $HOME/hookshot.log"
  9. """
  10. environment = "production"
  11. branch = "master"
  12. port = 4000
  13. env.use_ssh_config = True
  14. home = "/home/site"
  15. log = "%s/hookshot.log" % home
  16. current = "%s/%s/current" % (home, environment)
  17. # principal command to run upon update
  18. command = "cd %s && git pull && bundle exec jekyll build >> %s" % (current, log)
  19. def start():
  20. run(
  21. "cd %s && forever start -l %s -a deploy/hookshot.js -p %i -b %s -c \"%s\""
  22. % (current, log, port, branch, command)
  23. )
  24. def stop():
  25. run(
  26. "cd %s && forever stop deploy/hookshot.js -p %i -b %s -c \"%s\""
  27. % (current, port, branch, command)
  28. )
  29. def restart():
  30. run(
  31. "cd %s && forever restart deploy/hookshot.js -p %i -b %s -c \"%s\""
  32. % (current, port, branch, command)
  33. )