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.