Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- It is a good practice to usually run fabric directly from is
- directory folder
- to install:
- pip install fabric3
- to run (in fabfile current directory):
- fab test
- @author: Marco Boaretto
- """
- import time
- from fabric.api import env
- from fabric.api import puts
- from fabric.api import put
- from fabric.api import cd
- from fabric.api import sudo
- from fabric.api import hide
- from fabric.api import execute
- from fabric.api import task
- import warnings
- warnings.filterwarnings("ignore")
- env.hosts = ['user@0.0.0.0']
- remote_folder = 'remote/foler/path'
- def push():
- # Push script in remote folder
- put('teste_1.py', remote_folder)
- def runbg():
- # Run script in background
- with cd(remote_folder):
- command = 'your command here'
- """
- the use of 'nohup' and '&> /dev/null < /dev/null &) && /bin/true'
- allows the script to run in background
- """
- sudo('(nohup %s &> /dev/null < /dev/null &) && /bin/true' % command)
- def deploy():
- start = time.time()
- #hide all info to run smoothly
- with hide('running', 'stdout', 'stderr'):
- push()
- runbg()
- puts(' ________')
- puts('< execution finished in %.2fs >' % (time.time() - start))
- puts(' ________')
Add Comment
Please, Sign In to add comment