Python footstep management tool supervisor=3.3.0 installation, use. Based on Linux systems.

Source: Internet
Author: User

First, install the relevant package

sudo apt-get install Python-pip #python的安装包的工具

sudo apt-get install Python-dev #python在linux系统运行就需要安装的中间包

sudo pip install supervisor==3.3.0

Second, Production supervisor configuration

Su #切换到root用户才能生产配置文件

echo_supervisord_conf >/etc/supervisord.conf #生产配置文件

Third, add test script

Cd/home

VI test.py

Copy the code inside, save the exit: wq!

#----------------------------------------------------------------------------#

#coding =utf-8
#author: XH
#file: test.py

Import Time
Import datetime
Import OS

while True:
Savepath= "/home/"
if not os.path.exists (Savepath): # Determines if the path to the file exists and does not exist to create
Os.mkdir (Savepath)
Filepath= "/home/test.txt"
Filewrite=open (FilePath, "a") #追加的方式写入
Filewrite.write (str (Datetime.datetime.now ()))
Time.sleep (5)

#--------------------------------------------------------------------------#

Iv. Editing the configuration document

sudo vi/etc/supervisord.conf

Add the following code after the last line

[Program:testproess] #TestProess进程名

command=python/home/test.py #执行脚本路径

Autostart=true #是否支持自动启动

Autorestart=true #是否支持自动重新启动

Stdout_logfile=/tmp/supervisor.log #日志 (log path immutable)

#上面如果要管理多个, copy multiple, then configure the path

[Inet_http_server] #inet (TCP) server disabled by default
port=127.0.0.1:9009 #浏览器访问地址
Username=user # Client Login account
password=123 # Client Login Password

Save exit: wq!

Five, start supervisor

Supervisord-c/etc/supervisord.conf #启动命令

Supervisorctl Reload #重启命令, a reboot is required each time the configuration is modified

Supervisorctl Status #查看状态

Open Browser, enter 127.0.0.1:9009, can be managed by Web page

Python footstep management tool supervisor=3.3.0 installation, use. Based on Linux systems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.