Python的tornado部署

  1. 添加用户wls81并设置为sudo账户
    adduser wls81
    passwd wls81
    vim /etc/sudoers
    添加下面内容:
    wls81 ALL=(ALL:ALL) ALL

  2. 切换账号并创建必要文件夹
    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

  3. 安装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

  4. 安装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 &

  5. 安装所需的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

  6. 指定虚拟环境的python脚本的版本
    cd /var/python
    virtualenv py2 --python=python2.7
    source /var/python/py2/bin/activate

  7. 安装如下的package
    pip install numpy1.13.3
    pip install pandas
    0.20.3
    pip install scipy0.19.1
    pip install PyWavelets
    0.5.2
    pip install PeakUtils
    pip install psycopg22.7.5
    pip install matplotlib
    2.1.0
    pip install flask0.12.2
    pip install tornado
    4.5.3
    pip install sklearn
    pip install SQLAlchemy1.2.10
    pip install pycryptodome
    3.6.4
    pip install futures

  8. 关闭pypi并安装supervisor
    deactivate
    sudo apt-get install -y supervisor

  9. 配置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

  10. 创建并配置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 testing

    directory=/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=info

    redirect_stderr=false

  11. user的scv文件
    users_201808.csv上传到目录:var/log/supervisor/
    源代码上传到目录:/var/python/earlywarning/

  12. 配置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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值