beeminder / road

Beebrain and Visual Graph Editor
http://graph.beeminder.com
Other
13 stars 3 forks source link

Deploy script for Beebrain #44

Open dreeves opened 5 years ago

dreeves commented 5 years ago
### Desiderata
- [ ] Hunt down deploy.sh (we thought it was in this repo but it's not)
- [ ] Robust up and generalize the deploy script

Bee has a deploy script -- deploy.sh here in the beebrain repo -- for Beebrain but it needs robusted up and generalized so people besides her can actually use it.

Currently it assumes her personal aliases for the servers and probably other such junk. So it's sort of rudimentary but with minimal modification can be run by anyone with beeminder-user access to servers.

Here's how deploys happen currently:

  1. Danny or Uluc (or an open source contributor!) says "check out the new hotness in the beebrain repo"
  2. Danny uses Automon to convince himself it doesn't break things
  3. Danny updates the version number at the top of package.json and merges/pushes to master
  4. Danny asks Bee to deploy what's in the master branch of the beebrain (aka road) repo to production
  5. Bee runs ./deploy.sh
  6. Danny does "import from GitHub" on road.glitch.me and occasionally road-staging.glitch.me

Cognata

Verbata: deploy scripts, infrastructure, deploying beebrain, beebody adjacent, web hosting,

bsoule commented 4 years ago

I started a deploy script, but i'm not so very smart at bash scripting, so I haven't figured out how to do all the things via ssh or using bash commands or whatever. Here is what I do:

date=`date +%Y%m%d_%H%M`
server=fshr # i have named entries for each of the servers in my ssh config; fshr, germ, hop

# 1. open up the jsbrain logs in a different terminal (there's actually a 
# detached screen under the beeminder account on each server that's named 
# jsbrain, which is running `pm2 logs jsbrain`, so the following just connects 
# to that screen):
ssc beeminder@$server jsbrain

# 2. make a fallback branch in jsbrain dir using timestamp
ssh beeminder@$server "cd /var/www/jsbrain; git branch $date"
# blist=`ssh beeminder@$server 'cd /var/www/jsbrain; git branch'`

# 3. only keep the last 8 checkpoints
ssh beeminder@$server 
cd /var/www/jsbrain/
git branch # lists all the branches
git branch -D $oldestbranch

# 4. gently stop resque
ssh beeminder@$server
sudo god stop resque
# this does not actually do a gentle stop, i think we have to do something to 
# our resque config or something to get it to respond gently? anyhow, so I watch
# the resque queues until they're empty, or i just go visit resque web and 
# requeue anything that gets killed by this.

# 5. check that it's all quiesced
# Look at the tail of the jsbrain logs. Is it quiet now? It should be because there 
# should no longer be any workers on this server sending stuff to this jsbrain instance

# 7. git pull
ssh beeminder@$server
cd /var/www/jsbrain/
git pull

  # 8. cd jsbrain_server
  cd jsbrain_server

  # 9. npm install
  npm install

  # 10. reload jsbrain
  pm2 reload jsbrain

  # 11. restart god
  sudo god start resque

# 12. look at the jsbrain logs again and see that they are starting up again and 
# getting new jobs and there aren't any errors.

# 13. repeat for the other 2 servers.