-
添加用户wls81并设置为sudo账户
adduser wls81
passwd wls81
vim /etc/sudoers
添加下面内容:
wls81 ALL=(ALL:ALL) ALL -
切换账号并创建必要文件夹
su – wls81/var/python/earlywarning
cd /var/
sudo mkdir python
sudo chown -R wls81 python
cd /var/python
mkdir earlywarning/usr/local/share/python
cd /usr/local/share
sudo mkdir python
sudo chown -R wls81 python -
安装pip和设置(wls81账户操作)
sudo apt-get install -y python-pip~/.pip/
cd ~
mkdir .pip
cd .pip/
touch pip.conf
vim pip.conf
添加下面内容:
[global]
index-url=http://localhost:10086/simple
source ~/.bashrc -
安装pypiserver或者拷贝pypiserver
scp -r localdir wls81@rootip:rootdir
244:/usr/local/share/python/pypi/pypi
205:/var/python/pypi
206:/var/python/pypi
pip install pypiserver-1.2.2-py2.py3-none-any.whl
pip install virtualenv-16.0.0-py2.py3-none-any.whl
启动pypiserver并后台执行
nohup pypi-server -p 10086 /var/python/pypi & -
安装所需的package
sudo apt-get install -y gcc-4.9
sudo apt-get install -y g+±4.9
sudo apt-get install -y libsm6
sudo apt-get install -y libxext-dev
sudo apt-get install -y libfreetype6-dev
sudo apt-get install -y libxft-dev
sudo apt-get install -y python-tk -
指定虚拟环境的python脚本的版本
cd /var/python
virtualenv py2 --python=python2.7
source /var/python/py2/bin/activate -
安装如下的package
pip install numpy1.13.3
pip install pandas0.20.3
pip install scipy0.19.1
pip install PyWavelets0.5.2
pip install PeakUtils
pip install psycopg22.7.5
pip install matplotlib2.1.0
pip install flask0.12.2
pip install tornado4.5.3
pip install sklearn
pip install SQLAlchemy1.2.10
pip install pycryptodome3.6.4
pip install futures -
关闭pypi并安装supervisor
deactivate
sudo apt-get install -y supervisor -
配置supervisor
cd /var/log
sudo chown -R wls81 supervisor
sudo vim /etc/supervisor/supervisord.conf
添加如下内容:
[inet_http_server]
port=0.0.0.0:9001
username = wls81
password = wls81[unix_http_server]
username = wls81
password = wls81[supervisorctl]
username = wls81
password = wls81 -
创建并配置tornado_earlywarning_service
sudo touch /etc/supervisor/conf.d/tornado_earlywarning_service.conf
sudo vim /etc/supervisor/conf.d/tornado_earlywarning_service.conf
添加如下内容:
[program:tornado_earlywarning_service]
user = wls81
command= /var/python/py2/bin/python /var/python/earlywarning/tornado_earlywarning.py --env testingdirectory=/var/python/earlywarning
autostart=true
autorestart=true
startsecs=2
stderr_logfile=/var/log/supervisor/tornado_earlywarning_service_err.log
stdout_logfile=/var/log/supervisor/tornado_earlywarning_service_out.log
loglevel=inforedirect_stderr=false
-
user的scv文件
users_201808.csv上传到目录:var/log/supervisor/
源代码上传到目录:/var/python/earlywarning/ -
配置supervisor和对应的启动的命令
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/log/supervisor.sock
启动 关闭 重启 supervisor
sudo /etc/init.d/supervisor start
sudo /etc/init.d/supervisor stop
sudo /etc/init.d/supervisor restart
启动 关闭 重启 tornado_earlywarning_service
sudo supervisorctl status tornado_earlywarning_service
sudo supervisorctl start tornado_earlywarning_service
sudo supervisorctl restart tornado_earlywarning_service
Python的tornado部署
最新推荐文章于 2020-12-24 14:47:02 发布