Skip to content

Instantly share code, notes, and snippets.

@jasonrhodes
Created September 6, 2014 18:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrhodes/a879bf384c521c1a9c67 to your computer and use it in GitHub Desktop.
Save jasonrhodes/a879bf384c521c1a9c67 to your computer and use it in GitHub Desktop.
My git post-receive hook for Digital Ocean -- I make a bare repo in /var/repos/{reponame}/app.git and then add this code to the post-receive hook in app.git/hooks then set up a remote via ssh to the app.git folder
#!/bin/sh
# Store git files in a different directory than the repo
git --work-tree=/var/www/meatspace-markov-memeify --git-dir=/var/repos/meatspace-markov-memeify/app.git checkout -f
# Install npm deps
cd /var/www/meatspace-markov-memeify && npm install
# If index.js is running, restart--otherwise start!
forever restart --spinSleepTime 10000 --minUptime 1000 /var/www/meatspace-markov-memeify/index.js --port=8000 || forever start --spinSleepTime 10000 --minUptime 1000 /var/www/meatspace-markov-memeify/index.js --port=8000
# If listen.js is running, restart--otherwise start!
forever restart --spinSleepTime 10000 --minUptime 1000 /var/www/meatspace-markov-memeify/listen.js || forever start --spinSleepTime 10000 --minUptime 1000 /var/www/meatspace-markov-memeify/listen.js
@jasonrhodes
Copy link
Author

Starting to think I should keep the forever stuff written in my repo so i can edit it and push changes. Hmm yeah prolly.

@jajourda
Copy link

jajourda commented Mar 6, 2015

What is your development/deployment workflow with digitalocean apps like this? Do you develop locally and then push to a development server (on port 3000) for test features and only conditionally push up to a production server? Would love some insight into this, any articles, personal experience greatly appreciated. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment