使用
echo_supervisord_conf > /etc/supervisord.conf下面两行是该配置文件的最后不用修改,这里说下意思,表示的是/etc这个文件夹下.ini文件就是要启动的文件。
[include] files = /etc/supervisor/*.ini下面就是需要运行的文件的配置,这个文件的位置是 /usr/local/etc/supervisor.d/spider.ini
command=/data/p2pSearch/start.sh # 进程名 process_name=%(program_name)s # 进程数 numprocs=1 # supervisor启动的时候是否随着同时启动,默认True autostart=true # 当程序exit的时候,这个program不会自动重启,默认unexpected # 设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定义的 autorestart=true # 这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1 startsecs=1 # 日志输出 stderr_logfile=/data/p2pSearch/logs/p2papp_err.log stdout_logfile=/data/p2pSearch/logs/p2papp_out.log #把 stderr 重定向到 stdout,默认 false redirect_stderr = false #stdout 日志文件大小,默认 50MB stdout_logfile_maxbytes = 1024MB stderr_logfile_maxbytes = 1024MB #stdout 日志文件备份数 stdout_logfile_backups = 10 stderr_logfile_backups = 10因为用了virtualenv运行程序所以我用了一个shell脚本,并给定读的权限
chmod 777 start.shstart.sh内容如下
#! /bin/bash cd /data/p2pSearch/ source p2p/bin/activate python3 p2papp.py然后查看任务
supervisorctl如果报错
supervisorctl error: <class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib64/python2.7/socket.py line: 224查看
ps -ef |grep supervisor然后杀掉进程
sudo pkill -f supervisord查看任务
supervisorctl重启 可以看到任务状态
[root@server supervisor]# supervisorctl p2papp RUNNING pid 29931, uptime 0:00:09表示成功了
转载于:https://www.cnblogs.com/c-x-a/p/10232520.html
相关资源:JAVA上百实例源码以及开源项目