Linux2019. 4. 23. 13:29

service나 systemctl 을 통해 restart하는거야..

걍 stop + start 하면 되는데 reload는 어떻게 구현되나 궁금해서 검색중

흐음.. 몇개 찾아보는데 SIGHUP을 보내는건가?

 

ExecReload=
Commands to execute to trigger a configuration reload in the service. This argument takes multiple command lines, following the same scheme as described for ExecStart= above. Use of this setting is optional. Specifier and environment variable substitution is supported here following the same scheme as for ExecStart=.

One additional, special environment variable is set: if known, $MAINPID is set to the main process of the daemon, and may be used for command lines like the following:

/bin/kill -HUP $MAINPID
Note however that reloading a daemon by sending a signal (as with the example line above) is usually not a good choice, because this is an asynchronous operation and hence not suitable to order reloads of multiple services against each other. It is strongly recommended to set ExecReload= to a command that not only triggers a configuration reload of the daemon, but also synchronously waits for it to complete.

ExecStop=
Commands to execute to stop the service started via ExecStart=. This argument takes multiple command lines, following the same scheme as described for ExecStart= above. Use of this setting is optional. After the commands configured in this option are run, it is implied that the service is stopped, and any processes remaining for it are terminated according to the KillMode= setting (see systemd.kill(5)). If this option is not specified, the process is terminated by sending the signal specified in KillSignal= when service stop is requested. Specifier and environment variable substitution is supported (including $MAINPID, see above).

Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by queuing some form of termination signal for it), but does not wait for it to do so. Since the remaining processes of the services are killed according to KillMode= and KillSignal= as described above immediately after the command exited, this may not result in a clean stop. The specified command should hence be a synchronous operation, not an asynchronous one.

Note that the commands specified in ExecStop= are only executed when the service started successfully first. They are not invoked if the service was never started at all, or in case its start-up failed, for example because any of the commands specified in ExecStart=, ExecStartPre= or ExecStartPost= failed (and weren't prefixed with "-", see above) or timed out. Use ExecStopPost= to invoke commands when a service failed to start up correctly and is shut down again. Also note that the stop operation is always performed if the service started successfully, even if the processes in the service terminated on their own or were killed. The stop commands must be prepared to deal with that case. $MAINPID will be unset if systemd knows that the main process exited by the time the stop commands are called.

Service restart requests are implemented as stop operations followed by start operations. This means that ExecStop= and ExecStopPost= are executed during a service restart operation.

It is recommended to use this setting for commands that communicate with the service requesting clean termination. For post-mortem clean-up steps use ExecStopPost= instead.

[링크 : https://www.freedesktop.org/software/systemd/man/systemd.service.html]

[링크 : https://serverfault.com/questions/767360/how-to-configure-systemd-to-kill-and-restart-a-daemon-on-reload]

 

+

$ systemctl cat nginx | grep ExecReload= 
Or by running: 

$ systemctl show nginx.service --property=ExecReload 
On my system, I get: 

ExecReload=/usr/bin/kill -HUP $MAINPID

[링크 : https://superuser.com/questions/710986/how-to-reload-nginx-systemctl-or-nginx-s]

'Linux' 카테고리의 다른 글

linux 링크속도 줄이기  (0) 2019.04.25
ip별 대역폭 제한하기  (0) 2019.04.25
ata1 comreset failed (errno=-16)  (0) 2019.04.19
crontab 실행 시간 조절하기  (0) 2019.04.18
디렉토리내 중복 파일 확인하기  (0) 2019.04.18
Posted by 구차니