服务器上已经运行了一个supervisord的服务 不过是在root权限下 在线上是没有权限的,自己想是否可以自己运行一个实例呢 研究后发现是可以
查看:
$ supervisord -h
supervisord -- run a set of applications as daemons.
Usage: /bin/supervisord [options]
Options:
-c/--configuration FILENAME -- configuration file
-n/--nodaemon -- run in the foreground (same as 'nodaemon true' in config file)
-h/--help -- print this usage message and exit
-v/--version -- print supervisord version number and exit
-u/--user USER -- run supervisord as this user (or numeric uid)
-m/--umask UMASK -- use this umask for daemon subprocess (default is 022)
-d/--directory DIRECTORY -- directory to chdir to when daemonized
-l/--logfile FILENAME -- use FILENAME as logfile path
-y/--logfile_maxbytes BYTES -- use BYTES to limit the max size of logfile
-z/--logfile_backups NUM -- number of backups to keep when max bytes reached
-e/--loglevel LEVEL -- use LEVEL as log level (debug,info,warn,error,critical)
-j/--pidfile FILENAME -- write a pid file for the daemon process to FILENAME
-i/--identifier STR -- identifier used for this instance of supervisord
-q/--childlogdir DIRECTORY -- the log directory for child process logs
-k/--nocleanup -- prevent the process from performing cleanup (removal of
old automatic child log files) at startup.
-a/--minfds NUM -- the minimum number of file descriptors for start success
-t/--strip_ansi -- strip ansi escape codes from process output
--minprocs NUM -- the minimum number of processes available for start success
--profile_options OPTIONS -- run supervisord under profiler and output
results based on OPTIONS, which is a comma-sep'd
list of 'cumulative', 'calls', and/or 'callers',
e.g. 'cumulative,callers')
发现增加一个-k参数 修改配置的pid什么就行了
配置文件如下:
#supervisord进程处理
#日志目录创建
SUPERVISOR_LOG_DIR=/data/logs/supervisor
if [ ! -d "${SUPERVISOR_LOG_DIR}" ]; then
CMD=$CMD"mkdir -p ${SUPERVISOR_LOG_DIR};"
fi
#进程停止
SUPERVISORPIDFILE=${SUPERVISOR_LOG_DIR}/supervisord.pid
if [ -f ${SUPERVISORPIDFILE} ]; then
PID=$(cat $SUPERVISORPIDFILE)
CMD=$CMD"kill -15 ${PID};"
fi
#重启进程
SUPERVISOR_CONF_FILE="${ROOT}/supervisor.d/${DEPLOY_ENV}/supervisord.conf"
CMD=$CMD"supervisord -k -c ${SUPERVISOR_CONF_FILE};"
效果图: