From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CD804138334 for ; Mon, 22 Oct 2018 23:10:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 75FA7E0874; Mon, 22 Oct 2018 23:10:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3699DE0874 for ; Mon, 22 Oct 2018 23:10:03 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 121A9335C8C for ; Mon, 22 Oct 2018 23:10:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 87B483F0 for ; Mon, 22 Oct 2018 23:09:58 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1540248565.aacf841de4983ab33755081a6f69cdf5e3a47007.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: / X-VCS-Repository: proj/openrc X-VCS-Files: supervise-daemon-guide.md X-VCS-Directories: / X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: aacf841de4983ab33755081a6f69cdf5e3a47007 X-VCS-Branch: master Date: Mon, 22 Oct 2018 23:09:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: eda1b77f-5b4c-400d-b98c-cfeb793c97bb X-Archives-Hash: 5e40ef8ef8a99b7518a738c805602436 commit: aacf841de4983ab33755081a6f69cdf5e3a47007 Author: William Hubbs gmail com> AuthorDate: Mon Oct 22 22:49:25 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Oct 22 22:49:25 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=aacf841d supervise-daemon-guide.md: re-format and add more variables supervise-daemon-guide.md | 65 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/supervise-daemon-guide.md b/supervise-daemon-guide.md index ec885e71..0b15a858 100644 --- a/supervise-daemon-guide.md +++ b/supervise-daemon-guide.md @@ -7,44 +7,73 @@ terminates unexpectedly. The following is a brief guide on using this capability. -## Use Default start, stop and status functions +* Use Default start, stop and status functions + If you write your own start, stop and status functions in your service + script, none of this will work. You must allow OpenRC to use the default + functions. -If you write your own start, stop and status functions in your service -script, none of this will work. You must allow OpenRC to use the default -functions. +* Daemons must not fork + Any deamon that you would like to have monitored by supervise-daemon + must not fork. Instead, it must stay in the foreground. If the daemon + forks, the supervisor will be unable to monitor it. -## Daemons must not fork + If the daemon can be configured to not fork, this should be done in the + daemon's configuration file, or by adding a command line option that + instructs it not to fork to the command_args_foreground variable shown + below. -Any deamon that you would like to have monitored by supervise-daemon -must not fork. Instead, it must stay in the foreground. If the daemon -itself forks, the supervisor will be unable to monitor it. - -If the daemon can be configured to not fork, this should be done in the -daemon's configuration file, or by adding a command line option that -instructs it not to fork to the command_args_foreground variable shown -below. - -## Variable Settings +# Variable Settings The most important setting is the supervisor variable. At the top of your service script, you should set this variable as follows: +``` sh supervisor=supervise-daemon +``` Several other variables affect the way services behave under supervise-daemon. They are documented on the openrc-run man page, but I will list them here for convenience: +``` sh pidfile=/pid/of/supervisor.pid +``` If you are using start-stop-daemon to monitor your scripts, the pidfile is the path to the pidfile the daemon creates. If, on the other hand, you are using supervise-daemon, this is the path to the pidfile the supervisor creates. -command_args_foreground should be used if the daemon you want to monitor +``` sh +command_args_foreground="arguments" +``` + +This should be used if the daemon you want to monitor forks and goes to the background by default. This should be set to the command line option that instructs the daemon to stay in the foreground. -This is very early support, so feel free to file bugs if you have -issues. +``` sh +respawn_delay +``` + +This is the number of seconds to delay before attempting to respawn a +supervised process after it dies unexpectedly. +The default is to respawn immediately. + +``` sh +respawn_max=x +``` + +This is the maximum number of times to respawn a supervised process +during the given respawn period. The default is unlimited. + +``` sh +respawn_period=seconds +``` + +This works in conjunction with respawn_max and respawn_delay above to +decide if a process should not be respawned for some reason. + +For example, if respawn_period is 60, respawn_max is 2 and respawn_delay +is 3 and a process dies more than 4 times, the process will not be +respawned and the supervisor will terminate.