sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libbz2-dev libsqlite3-dev wget git
git config --global user.name ""
git config --global user.email ""
Reference: https://linuxize.com/post/how-to-install-python-3-7-on-ubuntu-18-04/
Instead of installing from source, we want to be able to use multiple versions of python. PyEnv is a great choice!
curl https://pyenv.run | bash
# Copy pyenv initialization code into ~/.bashrc
exec $SHELL
Reference https://github.com/pyenv/pyenv-installer
pyenv install 3.7.1
pyenv global 3.7.1
mkdir new-awesome-project
pyenv virtualenv 3.7.1 new-awesome-project
cd new-awesome-project
echo "new-awesome-project" > .python-version
Reference: https://medium.com/@martinlabs/my-python-development-workflow-with-pyenv-2bfbc03a15a1
mkdir ta-lib
cd ta-lib
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib
sudo ./configure
sudo make
sudo make install
pip install ta-lib
On your server,
mkdir algoName
echo "virtualenv-name" > algoName/.python-version
mkdir algoName.git
touch algoName.git/hooks/post-receive
vim algoName.git/hooks/post-receive
chmod +x algoName.git/hooks/post-receive
Update post-receive
file with the following:
#!/bin/sh
git --work-tree=/home/ubuntu/applications/algoName --git-dir=/home/ubuntu/applications/algoName.git checkout -f
cd /home/ubuntu/applications/algoName
pip install -r requirements.txt
On your computer
git init
echo ".env" > .gitignore
git add .
git commit -am "initial commit"
git remote add production ssh://ubuntu@ip/[path_to_application_dir].git
git push production master
- You can always start directly by just running python app.py, however the downside of this is if your algorithm crashes or your server reboots or you terminate your terminal session, your algorithm will not be running anymore. There are many ways to overcome this. What we will do is to use a production battled solution with a good balance for simplicity - PM2, a process manager that daemonizes the process of your running algorithm.
sudo apt install nodejs
sudo apt install npm
npm install pm2@latest -g
pm2 ecosystem
Edit your ecosystem.config.js
To start application
pm2 start ecosystem.config.js --env production
pm2 save
To view logs
pm2 logs name
Reference: