Last active
March 19, 2017 09:49
-
-
Save tonywangcn/4d7af9cf80fc89f76779abb8506dbd90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
env.hosts = [ | |
'10.211.55.12:32772', | |
'10.211.55.12:32773', | |
'10.211.55.12:32774', | |
] | |
# Set the username | |
env.user = "root" | |
# Set the password [NOT RECOMMENDED] | |
env.password = "test123" | |
@parallel | |
def install(): | |
cmd = "celery -A test_celery worker --app=test_celery.celeryapp:app --concurrency=10 --loglevel=debug" | |
run("apt-get install dtach && apt-get install -y python-pip && pip install celery && pip install requests && pip install pymongo") | |
with settings(warn_only=True): | |
runResult = run("mkdir -p /root/code/test_celery") | |
if runResult.return_code == 1: | |
print 'file exists' | |
put("./test_celery/celeryapp.py", "/root/code/test_celery") | |
put("./test_celery/run_tasks.py", "/root/code/test_celery") | |
put("./test_celery/tasks.py", "/root/code/test_celery") | |
put("./test_celery/ua.txt", "/root/code/test_celery") | |
put("./test_celery/__init__.py", "/root/code/test_celery") | |
with cd("/root/code"): | |
result = run("ls -l") | |
run('dtach -n `mktemp -u /tmp/%s.XXXX` %s' % ('dtach', cmd)) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment