In [1]:
from fabric.api import *
env.host_string="ec2-54-201-254-197.us-west-2.compute.amazonaws.com"
env.user = "ubuntu"
env.key_filename = ['/home/zzz/Downloads/Stevens-rzeng3.pem']
In [2]:
# run a command on the server to make sure you're connected
run('uname -a')
Out[2]:
In [3]:
# stop the service for your project so you can edit the code
sudo('service myproject stop')
Out[3]:
In [4]:
# stop nginx so you can use port 41593 for testing
sudo('service nginx stop')
Out[4]:
In [34]:
# download the current code for your project
get('myproject.py')
Out[34]:
In [35]:
# see what directory your currently in on the local machine
!pwd
In [5]:
import os
os.chdir('ec2-54-201-254-197.us-west-2.compute.amazonaws.com')
In [37]:
# checking to make sure we're in the right working directory
!pwd
In [7]:
ls
In [9]:
# edit the code in a separate window, feel free to use my code
put('myproject.py')
Out[9]:
In [56]:
# if you are using my code with TextBlob make sure to install TextBlob to the chatbot env
with prefix('source activate chatbot'):
run('pip install textblob')
In [ ]:
# we need to use our chatbot virtual environment to run the server code
with prefix('source activate chatbot'):
run('python myproject.py')
#if you need to stop the server script, just select this cell and click the stop button at the top
In [8]:
# after you've stopped the server, make sure it's not still running remotely
sudo('killall python')
Out[8]:
In [11]:
sudo('service myproject start')
sudo('service nginx start')
Out[11]:
In [ ]: