Skip to content

Instantly share code, notes, and snippets.

@astrotars
Last active May 5, 2020 11:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astrotars/d2976cae528e040cd1b4e792f26502e7 to your computer and use it in GitHub Desktop.
Save astrotars/d2976cae528e040cd1b4e792f26502e7 to your computer and use it in GitHub Desktop.
from fabric.api import *
# host
env.hosts = ['104.248.51.33']
# username
env.user = 'root'
# or, specify path to server public key here:
env.key_filename = '~/.ssh/id_rsa.pub'
# specify path to deploy root dir - you need to create this
env.deploy_project_root = '/var/www/Winds'
def move():
# move to the correct directory
with cd('%s' % env.deploy_project_root):
# pull latest code
print('fetching updates from github')
sudo('git pull origin master')
def install():
# install dependencies for root build
sudo('cd %s' % (env.deploy_project_root + '/ && yarn install --production'))
# install dependencies for api build
sudo('cd %s' % (env.deploy_project_root + '/api && yarn install --production'))
def restart():
# restart pm2
sudo('cd %s' % (env.deploy_project_root + '/ && pm2 restart all --update-env'))
def deploy():
move()
install()
restart()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment