1. 安装supervisor
apt-get install supervisor
2.新建supervisor配置文件。使用以下命令在linux 命令行
echo_supervisord_conf > /etc/supervisord.conf
3. 修改supervisor配置文件
vim /etc/supervisord.conf
移至文件内容结尾supervisord.conf。加include,指定启动时,需要启动的程序。
[include] files = /etc/supervisor/conf.d/*.conf
3. 新增.net core 启动的配置文件
vim /etc/supervisor/conf.d/hwappService.conf
然后填写以下内容:
[program:hwappService] command=dotnet /root/data/example/hwapp/bin/Debug/netcoreapp1.1/hwapp.dll //要执行的命令 directory=/root/data/example/hwapp/bin/Debug/netcoreapp1.1/ //dll所在的文件夹 autostart=true autorestart=true stderr_logfile=/var/log/sampleMicroService.err.log //错误日志 stdout_logfile=/var/log/sampleMicroService.out.log //输出日志 user=root //用户 stopsignal=INT
备注:linux中 ~指的是 /user。如果不清楚~是啥。可以在linux是用echo ~ 打印出来。