62,269
社区成员
发帖
与我相关
我的任务
分享[program:ResultUploadSystem]
command=dotnet ResultUploadSystem.dll
directory=/aspnetcore/publish
autostart=true
autorestart=true
startretries=5
startsecs=1
user=root
priority=999
stderr_logfile=/var/log/ResultUploadSystem.err.log
stdout_logfile=/var/log/ResultUploadSystem.out.log
environment=ASPNETCORE_ENVIORNMENT=Production
stopsignal=INT
2020-02-13 20:53:39,175 WARN received SIGTERM indicating exit request
2020-02-13 20:53:39,176 INFO waiting for ResultUploadSystem to die
2020-02-13 20:53:40,270 INFO stopped: ResultUploadSystem (exit status 0)
2020-02-13 20:54:22,659 CRIT Supervisor is running as root. Privileges were not dropped because no user
is specified in the config file. If you intend to run as root, you can set user=root in the config file
to avoid this message.
2020-02-13 20:54:22,659 INFO Included extra file "/etc/supervisor/conf.d/ResultUploadSystem.ini" during p
arsing
2020-02-13 20:54:22,671 INFO RPC interface 'supervisor' initialized
2020-02-13 20:54:22,672 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-02-13 20:54:22,672 INFO supervisord started with pid 11658
2020-02-13 20:54:23,675 INFO spawned: 'ResultUploadSystem' with pid 11661
2020-02-13 20:54:25,275 INFO success: ResultUploadSystem entered RUNNING state, process has stayed up for
> than 1 seconds (startsecs)
2020-02-13 20:55:53,465 WARN received SIGTERM indicating exit request
2020-02-13 20:55:53,465 INFO waiting for ResultUploadSystem to die
2020-02-13 20:55:54,534 INFO stopped: ResultUploadSystem (exit status 0)
2020-02-13 20:56:36,912 CRIT Supervisor is running as root. Privileges were not dropped because no user
is specified in the config file. If you intend to run as root, you can set user=root in the config file
to avoid this message.
2020-02-13 20:56:36,912 INFO Included extra file "/etc/supervisor/conf.d/ResultUploadSystem.ini" during p
arsing
2020-02-13 20:56:36,924 INFO RPC interface 'supervisor' initialized
2020-02-13 20:56:36,924 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-02-13 20:56:36,924 INFO supervisord started with pid 11739
2020-02-13 20:56:37,932 INFO spawned: 'ResultUploadSystem' with pid 11742
2020-02-13 20:56:39,510 INFO success: ResultUploadSystem entered RUNNING state, process has stayed up for
> than 1 seconds (startsecs)
2020-02-13 20:58:07,467 WARN received SIGTERM indicating exit request
2020-02-13 20:58:07,467 INFO waiting for ResultUploadSystem to die
2020-02-13 20:58:08,542 INFO stopped: ResultUploadSystem (exit status 0)
2020-02-13 20:58:51,149 CRIT Supervisor is running as root. Privileges were not dropped because no user
is specified in the config file. If you intend to run as root, you can set user=root in the config file
to avoid this message.
2020-02-13 20:58:51,149 INFO Included extra file "/etc/supervisor/conf.d/ResultUploadSystem.ini" during p
arsing
2020-02-13 20:58:51,158 INFO RPC interface 'supervisor' initialized
2020-02-13 20:58:51,158 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-02-13 20:58:51,158 INFO supervisord started with pid 11824
2020-02-13 20:58:52,163 INFO spawned: 'ResultUploadSystem' with pid 11827
2020-02-13 20:58:53,763 INFO success: ResultUploadSystem entered RUNNING state, process has stayed up for
> than 1 seconds (startsecs)
2020-02-13 21:00:21,791 WARN received SIGTERM indicating exit request
2020-02-13 21:00:21,793 INFO waiting for ResultUploadSystem to die
2020-02-13 21:00:22,904 INFO stopped: ResultUploadSystem (exit status 0)
yum install epel-release
yum install -y supervisor
[program:my]
command=sh -c "while true; do echo $(date) && sleep 2; done"
3、重启supervisord
4、应该在supervisord的日志下看到任务program:my被成功启动,例子里它的进程id是1981:
CRIT Supervisor running as root (no user in config file)
INFO Included extra file "/etc/supervisor/conf.d/my.conf" during parsing
INFO RPC interface 'supervisor' initialized
CRIT Server 'unix_http_server' running without any HTTP authentication checking
INFO supervisord started with pid 1978
INFO spawned: 'my' with pid 1981
INFO success: my entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
观察是否supervisor还是存在意外被杀的情况,如果是,且换一台机器能工作正常,就能说明存在本机问题。
一般来说,supervisor管理的进程如果崩溃,supervisor应该重启一个任务,supervisor就是干这个的,它本身不应该崩溃。
比如在program:my的例子中,如果你运行kill 1981,手动杀掉进程1981,supervisor日志下可以看到任务重启,新的pid为3690:
INFO exited: my (terminated by SIGTERM; not expected)
INFO spawned: 'my' with pid 3690
INFO success: my entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)[root@localhost system]# systemctl status supervisord
● supervisord.service - Supervisor Daemon
Loaded: loaded (/usr/lib/systemd/system/supervisord.service; disabled; vendor preset: disabled)
Active: activating (start) since Fri 2020-02-14 22:46:46 CST; 6s ago
Cntrl PID: 11398 (supervisord)
Tasks: 16 (limit: 11344)
Memory: 56.9M
CGroup: /system.slice/supervisord.service
├─11398 /usr/bin/python3.6 /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
└─11401 dotnet ResultUploadSystem.dll
2月 14 22:46:46 localhost.localdomain systemd[1]: Starting Supervisor Daemon...
2月 14 22:46:46 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:46,477 CRIT Supervisor is running as root. Privileges>
2月 14 22:46:46 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:46,478 INFO Included extra file "/etc/supervisor/conf.>
2月 14 22:46:46 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:46,490 INFO RPC interface 'supervisor' initialized
2月 14 22:46:46 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:46,490 CRIT Server 'unix_http_server' running without >
2月 14 22:46:46 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:46,491 INFO supervisord started with pid 11398
2月 14 22:46:47 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:47,495 INFO spawned: 'ResultUploadSystem' with pid 114>
2月 14 22:46:49 localhost.localdomain supervisord[11398]: 2020-02-14 22:46:49,083 INFO success: ResultUploadSystem entered RUNNIN>
lines 1-18/18 (END)
[root@localhost system]# systemctl status supervisord
● supervisord.service - Supervisor Daemon
Loaded: loaded (/usr/lib/systemd/system/supervisord.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: timeout) since Fri 2020-02-14 22:43:56 CST; 30s ago
Process: 11207 ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf (code=exited, status=0/SUCCESS)
2月 14 22:43:56 localhost.localdomain systemd[1]: supervisord.service: Failed with result 'timeout'.
2月 14 22:43:56 localhost.localdomain systemd[1]: Failed to start Supervisor Daemon.
warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data
will be unavailable when application exits.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {e082db6b-b669-4b81-ad88-0b7e0ea8921e} may be persisted to storage
in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /aspnetcore/publish
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data
will be unavailable when application exits.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {11984272-1ced-4b93-8587-9f239fb37c6c} may be persisted to storage
in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /aspnetcore/publish
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data
will be unavailable when application exits.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {7c0d01f1-cbe1-49c7-a7e4-ba541f1b59a6} may be persisted to storage
in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /aspnetcore/publish
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /aspnetcore/publish
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
info: ResultUploadSystem.Controllers.AccountController[0]
Logged in admin.
info: ResultUploadSystem.Controllers.AccountController[0]
admin logged out.
info: ResultUploadSystem.Controllers.AccountController[0]
Logged in test.