<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1748&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / runit as a process supervisor]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1748</link>
		<description><![CDATA[The most recent posts in runit as a process supervisor.]]></description>
		<lastBuildDate>Sat, 19 May 2018 16:18:31 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=9270#p9270</link>
			<description><![CDATA[<p>I am reporting my efforts to get Runit integrated with OpenRC in a separate thread :-</p><p><a href="https://dev1galaxy.org/viewtopic.php?id=2078" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=2078</a></p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Sat, 19 May 2018 16:18:31 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=9270#p9270</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=9158#p9158</link>
			<description><![CDATA[<p>I was wanting to try replacing SysVinit with OpenRC. It appeared that the set up for runit under OpenRC was a little different. Therefore, the first thing to do was to back out of running stuff under runit. The easiest one for me to back out of as a test was bluetoothd.</p><div class="codebox"><pre><code>cd /etc/service
rm bluetoothd</code></pre></div><p>this has now stopped bluetoothd. It appears that in setting up the init links the command does not run if there is a conflicting set-up, so it is easiest to remove the links and then set them to the default.</p><div class="codebox"><pre><code>cd /etc/init.d
update-rc.d bluetooth remove
update-rc.d bluetooth defaults</code></pre></div><p>This has now re-instated the links in /etc/rc2.d etc.<br />The machine was rebooted and bluetoothd was running normally.</p><p>The next one to try was lxdm. I set up the links first and then stopped it under runit, as it may well crash X.</p><div class="codebox"><pre><code>cd /etc/init.d
update-rc.d lxdm remove
update-rc.d lxdm defaults</code></pre></div><p>I then logged out and switched to the console with <span class="bbc">&lt;CTRL&gt;&lt;ALT&gt;&lt;F1&gt;</span> and logged in as root</p><div class="codebox"><pre><code>cd /etc/service
rm lxdm
shutdown -r now</code></pre></div><p>This then came back normally with lxdm running under init.<br />It was now clear to put the remaining services under init, which in the case of my laptop was autofs and wicd.</p><div class="codebox"><pre><code>cd /etc/init.d
update-rc.d autofs remove
update-rc.d autofs defaults
update-rc.d wicd remove
update-rc.d wicd defaults

cd /etc/service
rm autofs wicd</code></pre></div><p>and then reboot. (Although this reboot could probably have waited until after the following step.)</p><p>All the services are now running normally and runsvdir is still running but not doing anything!<br />I edited /etc/inittab and commented out the line at the end which was running runsvdir, thus :-</p><div class="codebox"><pre><code>#runit-sysv maintscript -- BEGIN
#SV:123456:respawn:/etc/runit/2
#runit-sysv maintscript -- END</code></pre></div><p>A reboot then left everything running in a normal state. I will report on OpenRC in another thread.</p><p><a href="https://dev1galaxy.org/viewtopic.php?id=2072" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=2072</a></p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Wed, 16 May 2018 08:48:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=9158#p9158</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=8192#p8192</link>
			<description><![CDATA[<p>It was also necessary to update the run file for PostgreSQL so that it sets the version number correctly, now at 9.6.</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Mon, 02 Apr 2018 10:21:27 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=8192#p8192</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=8190#p8190</link>
			<description><![CDATA[<p><span class="bbu">Upgrading from Jessie to Ascii</span></p><p>When I upgraded my Jessie machine to Ascii, runit did not start. It should be started by a line added at the end of /etc/inittab. The upgrade had removed the start-up script from where it was. The script is now to be found as /etc/runit/2. The end of /etc/inittab should thus now be :-</p><div class="codebox"><pre><code>#-- runit begin
SV:123456:respawn:/etc/runit/2
#-- runit end</code></pre></div><p>and runit will then carry on supervising the processes which you have set up.</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Sun, 01 Apr 2018 16:03:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=8190#p8190</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7184#p7184</link>
			<description><![CDATA[<p>I did a bit of investigation into this matter myself, but the solution I came up with is far from elegant. Let&#039;s start with where runit currently stands in the Debian/Devuan universe. Runit can be used as PID 1, but for booting and shutting down, it depends on three different init scripts that in turn depend on sysvinit:</p><p>Booting:</p><p>/etc/init.d/rcS - Executes the symlinks to the actual startup scripts located in /etc/rc.d/S##xxxxxx with option &quot;start&quot;.<br />/etc/init.d/rmnologin - Removes the /etc/nologin file as the last step in the boot process, if DELAYLOGIN=yes.</p><p>Shutting down:</p><p>/etc/init.d/rc - Main runlevel control script.</p><p>If your end goal is to use runit along with sysvinit for booting and shutting down, this is not a problem. For simplicity, however, I wanted to use runit independent of anything else. Attempting to purge all sysvinit packages along with the initscripts package resulted in an unbootable system. To circumvent this problem, I manually compiled Void Linux&#039;s runit configs along with their executables for rebooting, shutting down, etc. This allowed the system to boot again. In my opinion, Void&#039;s implementation for runit is far superior to that of Devuan&#039;s. If Void&#039;s runit could be used for Devuan, there is one other package I would like to be able to remove: init-system-helpers. init-system-helpers, from the information I could find, is only useful for switching between sysvinit and systemd. I don&#039;t see how it&#039;s necessary if runit is being used as PID 1.</p>]]></description>
			<author><![CDATA[dummy@example.com (Customer Service Robot)]]></author>
			<pubDate>Fri, 19 Jan 2018 07:31:44 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7184#p7184</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6968#p6968</link>
			<description><![CDATA[<p>umm there&#039;s no easy to packager a specific way to find process for each daemon/service in the OS, a more generic way to find PID and top process must be found..</p><p>but in those days nothing its standard unless systemd! oughtch! oh no! what i said!</p>]]></description>
			<author><![CDATA[dummy@example.com (mckaygerhard)]]></author>
			<pubDate>Wed, 03 Jan 2018 16:05:41 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6968#p6968</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6965#p6965</link>
			<description><![CDATA[<p><span class="bbu">Apache2</span></p><p>Another interesting example is Apache. It seems that the way to start it is with &quot;apache2ctl start&quot; as that is the way to get the environment set-up correctly. This results in the daemon(s) running in the background. The &quot;run&quot; file should wait for the daemon(s) to stop. As apache produces a pid file, it is easy to find the top daemon. What we would like to do is &quot;wait $PID&quot;. Unfortunately this does not work as $PID is not a child of mine! It is, however, possible to look at /proc/$PID :-<br /><a href="https://stackoverflow.com/questions/1058047/wait-for-any-process-to-finish" rel="nofollow">https://stackoverflow.com/questions/105 … -to-finish</a></p><div class="quotebox"><blockquote><div><p>while [[ ( -d /proc/$PID ) &amp;&amp; ( -z `grep zombie /proc/$PID/status` ) ]]; do<br />&#160; &#160; sleep 1<br />done</p></div></blockquote></div><p>Although I got a syntactical error with this, so I ended up with this &quot;run&quot; file :-</p><div class="codebox"><pre class="vscroll"><code>#!/bin/sh -eu
exec 2&gt;&amp;1
echo &quot;executing /etc/sv/apache2/run&quot;

/usr/sbin/apache2ctl configtest
/usr/sbin/apache2ctl start

# allow time for the PID file to be written

n=0
until [ -s /var/run/apache2/apache2.pid ]
do
   if [ $n -gt 5 ]
   then
      echo &quot;/var/run/apache2/apache2.pid not found after ${n}s.
      exit 1
   fi
   n=$(( $n + 1 ))
   sleep 1
done

read PID &lt; /var/run/apache2/apache2.pid
echo &quot;apache2 running as pid ${PID}.&quot;

# wait for the $PID to stop

while [ -d /proc/$PID ] &amp;&amp; [ -z `grep zombie /proc/$PID/status` ]
do
    sleep 60
done</code></pre></div><p>I also set up a &quot;finish&quot; file as stopping the &quot;run&quot; script would not stop apache.</p><div class="codebox"><pre><code>#!/bin/sh
# exec 2&amp;&gt;1
echo &quot;calling /etc/sv/apache2/finish&quot;
/usr/sbin/apache2ctl stop</code></pre></div><p>I had wondered whether I could use chpst to put a lock on /proc/$PID or one of the files in that directory and then have a second copy of chpst to wait to get a lock on that file, to avoid the looping, but I though that it was best to avoid playing with the procfs!</p><p>I wonder whether one should take a different course of action if the $PID becomes a zombie?</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Wed, 03 Jan 2018 14:23:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6965#p6965</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6939#p6939</link>
			<description><![CDATA[<p>hi to all, i already now that this trheath its about a runit issues, but maybe a strategy move can be support upstart, that was used nomadays in winbuntu..</p><p>yeah unmantained but the point it&#039;s&#160; due it&#039;s excelent compatibility (no need of any change for usage alongside with sysvinit) </p><p>can be a strategy move to more distributions and non-linux OS found a cooperative way to stop the alienate systemd process</p><p>we must take in consideration the workload to manpowers in devuan, what happened when project grow so many more thant the amount of developer can support? will be good a little of cooperative help beetweent MANY and not litle distros</p>]]></description>
			<author><![CDATA[dummy@example.com (mckaygerhard)]]></author>
			<pubDate>Sun, 31 Dec 2017 03:43:16 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6939#p6939</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6932#p6932</link>
			<description><![CDATA[<p><span class="bbu">Postfix again</span></p><p>I was reviewing the setup for Postfix, and having a fiddle, when I discovered that I had misunderstood the flags to the &quot;master&quot; program. Under SysV init, master runs with &quot;-w&quot;, which launches it as a daemon, but does not return until the daemon is running correctly. If you omit the &quot;-w&quot; flag then master runs in the foreground, which is what we want! The set up then becomes very simple. All that is needed is a simple run file and you may setup logging if you wish. The &quot;echo&quot; in the run file is reported through the logging mechanism.</p><div class="codebox"><pre><code>cat &lt;&lt; EOF &gt; run
#!/bin/sh -eu
echo &quot;executing /etc/sv/postfix/run&quot;
/usr/sbin/postfix check
exec /usr/lib/postfix/master
EOF</code></pre></div><p>The &quot;-eu&quot; flags cause the script to fail on any unchecked errors. There is no need for a finish script. &quot;ps uaxf&quot; then reports :-</p><div class="codebox"><pre><code>root      2658  0.0  0.0   4100   688 ?        Ss   14:31   0:00  \_ runsv postfix
log       2662  0.0  0.0   4244  1240 ?        S    14:31   0:00      \_ svlogd -tt /var/svlogd/postfix
root      3697  0.0  0.0  36168  3820 ?        Ss   15:54   0:00      \_ /usr/lib/postfix/master
postfix   3810  0.0  0.0  38232  3724 ?        S    15:54   0:00          \_ pickup -l -t unix -u -c
postfix   3811  0.0  0.0  38280  3924 ?        S    15:54   0:00          \_ qmgr -l -t unix -u</code></pre></div><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Sat, 30 Dec 2017 16:15:19 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6932#p6932</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6754#p6754</link>
			<description><![CDATA[<p><span class="bbu">Package upgrades</span></p><p>I was wondering about package upgrades as it appears that many services are automatically stopped before an upgrade and restarted afterwards, or possibly simply restarted after the upgrade. To have a look at how this worked I had a look through a &quot;.deb&quot; file. I copied one over to somewhere safe :-</p><div class="codebox"><pre><code>cp /var/cache/apt/archives/apache2_2.4.10-10+deb8u11_amd64.deb .</code></pre></div><p>and then had a look with spacefm/Xarchiver, extracting the control.tar file into my safe area. In the &quot;postinst&quot; file near the end is the code fragment :-</p><div class="codebox"><pre><code># Automatically added by dh_installinit
if [ -x &quot;/etc/init.d/apache2&quot; ]; then
	update-rc.d apache2 defaults 91 09 &gt;/dev/null
	if [ -n &quot;$2&quot; ]; then
		_dh_action=restart
	else
		_dh_action=start
	fi
	invoke-rc.d apache2 $_dh_action || true
fi</code></pre></div><p>Indeed, prerm and postrm also use invoke-rc.d and update-rc.d to stop apache and then remove the init.d links.<br />Interestingly, only postrm makes reference to systemd.</p><p>I suspect that the quick workaround is to do an apt-get upgrade and stop it when it asks. You would then inspect the packages to be upgraded and if you spot any of the services you have under runit, you would stop them manually. Then you would actually do the upgrade and then you could restart the services! I&#039;m not sure that is the best answer! Runit&#039;s &quot;sv&quot; program does understand init.d and can be linked to from /etc/init.d</p><p><a href="http://smarden.org/runit/faq.html#lsb" rel="nofollow">http://smarden.org/runit/faq.html#lsb</a></p><p>So that might be a way to have your services handled safely, although I wonder whether any upgrades might want to overwrite the service&#039;s init.d script, which could lead to sv be overwritten!</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Sun, 17 Dec 2017 15:34:17 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6754#p6754</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6743#p6743</link>
			<description><![CDATA[<p><span class="bbu">Postgresql</span></p><p>The next service to try was postgresql. This proved to be a bit more complex, in that there was more to set up.<br />The command line according to the ps command was :-</p><div class="codebox"><pre><code>/usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf</code></pre></div><p>Logging was set up and then on putting this command into the run file it failed to run. The log file reported that postgres must not be run as root. &quot;chpst&quot; was then used to set the user and group to postgres:postgres. This then failed as it could not read the ssl certificate. &quot;chpst&quot; allows for a number of groups to be set so using postgres:postgres:ssl-cert seems to work, although postgres is already in the ssl-group in /etc/group! The next problem was that it needed the socket directory to be created in /var/run, which, as it is a tmpfs, disappears on a re-boot. It was also clear that the stats sub-directory also needed to be recreated. This can be done with install, to set up permissions and ownership in one command.</p><p>This then seems to work, but there are a number of directories involved and these may change with versions, indeed the version number is included in several of the directories. It therefore seemed reasonable to make these easy to configure. There is some documentation on clusters of databases, but I am only running one. It may be that the one database is called &quot;main&quot; by default and that that part of the path names should also be easy to configure.</p><p>The currently working set up is like this :-</p><div class="codebox"><pre class="vscroll"><code>mkdir /etc/sv/postgresql
cd /etc/sv/postgresql

cat &lt;&lt; EOF &gt; run
#!/bin/sh -eu
exec 2&gt;&amp;1

VERSION=&quot;9.4&quot;

PGBINROOT=&quot;/usr/lib/postgresql&quot;
RUNROOT=&quot;/var/run/postgresql&quot;
DATAROOT=&quot;/var/lib/postgresql&quot;
CONFROOT=&quot;/etc/postgresql&quot;

BINFILE=&quot;${PGBINROOT}/${VERSION}/bin/postgres&quot;
STATDIR=&quot;${RUNROOT}/${VERSION}-main.pg_stat_tmp&quot;
DATAFILE=&quot;${DATAROOT}/${VERSION}/main&quot;
CONFFILE=&quot;${CONFROOT}/${VERSION}/main/postgresql.conf&quot;

# create socket and stats directories

install -d -m 2775 -o postgres -g postgres ${RUNROOT} ${STATDIR}

exec chpst -u postgres:postgres:ssl-cert ${BINFILE} -D ${DATAFILE} -c config_file=${CONFFILE}
EOF

mkdir log
cat &lt;&lt; EOF &gt; log/run
exec chpst -ulog svlogd -tt /var/svlogd/postgresql
EOF

chmod a+x run log/run
mkdir /var/svlogd/postgresql
chown log /var/svlogd/postgresql

cd /etc/service
/etc/init.d/postgresql stop
update-rc.d postgresql disable
ln -s /etc/sv/postgresql .

tail -f /var/svlogd/postgresql/current</code></pre></div><p>Once you are happy that the log file is not producing lots of errors you can ^C out of it!</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Sat, 16 Dec 2017 16:04:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6743#p6743</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6675#p6675</link>
			<description><![CDATA[<p><span class="bbu">Current state<br /></span><br />across 2 machines, the following are running under runit :-</p><div class="codebox"><pre><code>slim
lxdm
autofs
bluetoothd
wicd
postfix</code></pre></div><p>For most of them it is simply the case of setting up a run file containing the command along with the flag to stop it from running as a daemon, but remain attached to stdin/stdout. With a few (lxdm) it is rather the case that you leave out the flag that causes it to become a daemon. It is probably a good idea to set up logging for most of them. It is only slightly more complex when the program really does want to run as a daemon, such as postfix.</p><p>There is the question of why the SysV init scripts are so complex. I think that these have evolved this way as they check that everything has been set up correctly and where possible put things in place that should be there. It is understandable that a general purpose distribution will want everything to just work out of the box. The price of this is perhaps that the mechanism becomes more complex. One of the complexities seems to be the setting up of a PID file. I think that this is necessary so that init is able to control the service, whereas this is probably not necessary under runit.</p><p>The services which I have set up do seem to be simpler, but it may be that they do actually work because they were originally set up under SysV init, which sorted out any problems!</p><p>If you are developing a new service or have one which is not set up for SysV init, then it may be easier to get it running under runit.</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Mon, 11 Dec 2017 10:46:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6675#p6675</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6587#p6587</link>
			<description><![CDATA[<p>I spotted another method of hanging for a daemon (rpc.nfsd) that detaches (in the Gentoo info).<br />The README file for the rpc.nfsd &quot;run&quot; says :-<br />&#160; &#160; </p><div class="quotebox"><blockquote><div><p>&quot;rpc.nfsd is a &quot;fake&quot; service implemented using lock-wedging. Doing it this way allows sv stop rpc.nfsd to work, by stopping it in the finish script.&quot;</p></div></blockquote></div><p>After it has started the daemon, which detaches, the run file then does this :-</p><div class="codebox"><pre><code>exec chpst -L supervise/runlock chpst -l supervise/runlock true</code></pre></div><p>The change process state program (chpst) uses the -L switch to open the file supervise/runlock for writing, and obtain an exclusive lock on it. It then runs another copy of chpst which similarly gets a lock on the same file and then runs and returns &quot;true&quot;.<br />The difference is that -L will fail immediately if it cannot get the lock, while -l will wait until it can get the lock. This line will therefore hang until it gets &quot;sv stop postfix&quot;, when it will terminate true so that &quot;finish&quot; will be executed, which is set up to actually stop postfix. This does work as described, once the control/t file was moved out of the way, which was by-passing killing off the &quot;run&quot; process. The normal shutdown proceedure continues as before.</p><p>The set up is now fairly simple as it is only necessary to set up &quot;run&quot; &amp; &quot;finish&quot; along with the logging.</p><div class="codebox"><pre><code>cd /etc/sv/postfix
cat &lt;&lt; EOF &gt; run
#!/bin/sh
exec 2&gt;&amp;1
echo &quot;executing /etc/sv/postfix/run&quot;
/usr/sbin/postfix start
exec chpst -L supervise/runlock chpst -l supervise/runlock true
EOF

cat &lt;&lt; EOF &gt; finish
#!/bin/sh
exec 2&gt;&amp;1
echo &quot;calling /etc/sv/postfix/finish&quot;
/usr/sbin/postfix stop
EOF

mkdir log
cat &lt;&lt; EOF &gt; log/run
exec chpst -ulog svlogd -tt /var/svlogd/postfix
EOF

chmod a+x run finish log/run</code></pre></div><p>the part of the output of ps uaxf relating to the postfix daemon looks like this :-</p><div class="codebox"><pre><code>root      2767  0.0  0.0   4100   696 ?        Ss   09:02   0:00  \_ runsv postfix
log       2768  0.0  0.0   4244   708 ?        S    09:02   0:00      \_ svlogd -tt /var/svlogd/postfix
root      2771  0.0  0.0   4104   652 ?        S    09:02   0:00      \_ chpst -l supervise/runlock true
root      2903  0.0  0.0  36168  3152 ?        Ss   09:02   0:00 /usr/lib/postfix/master -w
postfix   2904  0.0  0.0  38232  3884 ?        S    09:02   0:00  \_ pickup -l -t unix -u -c
postfix   2905  0.0  0.0  38280  3936 ?        S    09:02   0:00  \_ qmgr -l -t unix -u</code></pre></div><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Thu, 07 Dec 2017 09:57:39 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6587#p6587</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6552#p6552</link>
			<description><![CDATA[<p>The actual file set up in /etc/sv/postfix looks like this :-</p><div class="codebox"><pre><code># find /etc/sv/postfix/ -name &#039;*&#039; -ls
651625    4 drwxr-xr-x   5 root     root         4096 Dec  3 17:41 /etc/sv/postfix/
652292    4 -rwxr-xr-x   1 root     root           71 Nov 24 14:31 /etc/sv/postfix/finish
652288    4 -rwxr-xr-x   1 root     root          121 Dec  3 17:41 /etc/sv/postfix/run
656409    4 drwxr-xr-x   2 root     root         4096 Dec  3 17:04 /etc/sv/postfix/control
661485    4 -rwxr-xr-x   1 root     root           66 Dec  3 17:04 /etc/sv/postfix/control/t
652295    4 drwxr-xr-x   3 root     root         4096 Dec  1 16:41 /etc/sv/postfix/log
661408    4 -rwxr-xr-x   1 root     root           58 Dec  1 16:38 /etc/sv/postfix/log/run
661426    4 drwx------   2 root     root         4096 Dec  4 13:48 /etc/sv/postfix/log/supervise
661458    0 -rw-------   1 root     root            0 Dec  1 16:41 /etc/sv/postfix/log/supervise/lock
661461    4 -rw-r--r--   1 root     root           20 Dec  4 13:48 /etc/sv/postfix/log/supervise/status
661477    0 prw-------   1 root     root            0 Dec  1 16:41 /etc/sv/postfix/log/supervise/ok
661728    4 -rw-r--r--   1 root     root            4 Dec  4 13:48 /etc/sv/postfix/log/supervise/stat
652424    4 -rw-r--r--   1 root     root            5 Dec  4 13:48 /etc/sv/postfix/log/supervise/pid
652426    0 prw-------   1 root     root            0 Dec  1 16:41 /etc/sv/postfix/log/supervise/control
652309    4 drwx------   2 root     root         4096 Dec  4 13:48 /etc/sv/postfix/supervise
654580    0 -rw-------   1 root     root            0 Nov 23 11:20 /etc/sv/postfix/supervise/lock
661489    4 -rw-r--r--   1 root     root           20 Dec  4 13:48 /etc/sv/postfix/supervise/status
661277    0 prw-------   1 root     root            0 Nov 23 11:20 /etc/sv/postfix/supervise/ok
661390    4 -rw-r--r--   1 root     root            4 Dec  4 13:48 /etc/sv/postfix/supervise/stat
661388    4 -rw-r--r--   1 root     root            5 Dec  4 13:48 /etc/sv/postfix/supervise/pid
656413    0 prw-------   1 root     root            0 Dec  3 17:17 /etc/sv/postfix/supervise/control</code></pre></div><p>The supervise sub-directories are automatically set up by runsv.</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Mon, 04 Dec 2017 15:13:32 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6552#p6552</guid>
		</item>
		<item>
			<title><![CDATA[Re: runit as a process supervisor]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6551#p6551</link>
			<description><![CDATA[<p><span class="bbu">Postfix and shutdown</span></p><p>There is some further documentation on runit at Gentoo :-</p><p><a href="https://wiki.gentoo.org/wiki/Runit" rel="nofollow">https://wiki.gentoo.org/wiki/Runit</a></p><p>including some example run scripts to be found at :-</p><p><a href="https://gitlab.com/flussence/runit-scripts" rel="nofollow">https://gitlab.com/flussence/runit-scripts</a></p><p>thus they offer a postfix run file :-</p><p><a href="https://gitlab.com/flussence/runit-scripts/blob/master/mail-mta/postfix/run" rel="nofollow">https://gitlab.com/flussence/runit-scri … ostfix/run</a></p><p>I added in -d and corrected the paths. This does seem to work, although I notice that the sub-processes also have the -d flag.</p><div class="codebox"><pre><code>#!/bin/sh -eu
/usr/sbin/postfix check
exec /usr/lib/postfix/master -d</code></pre></div><p>Although &quot;master&quot; is in itself a process supervisor which looks after the various postfix programs. I think that this leads into questions that have been rising in my mind about shutdown. It is not very clear from the documentation how shutdown works if you only use runit as a process supervisor. As far as I can see the shutdown mechanism would use stage 3 of runit, if you were using runit as init. (As a supervisor, it is only stage 2).</p><p>With the run file running &quot;master&quot; directly (with the -d flag), as above, then on shutdown, /var/log/mail.info reports</p><div class="codebox"><pre><code>postfix/master[2795]: fatal: master_sigdeath: kill process group: No such process
postfix/postfix-script[4380]: fatal: the Postfix mail system is not running</code></pre></div><p>I think that the first line is &quot;master&quot; receiving a signal to stop. From /var/log/syslog I can sees that at shutdown ntpd (which is not under runit) exiting on signal 15 (TERM), so I would guess that that is what &quot;master&quot; has received. The second line above is probably from &quot;finish&quot;, which is being executed after &quot;run&quot; finishes and is therefore correct! The man page for &quot;shutdown&quot; says that &quot;All processes are first notified that the system is going down by the signal SIGTERM.&quot; I have assumed that any daemons run by SysV init would have their &quot;K&quot; scripts in /etc/rc0.d run at shutdown, although I can&#039;t currently find the documentation on that!</p><p>As the couple of daemons that I am trying under runit are not part of the SysV init, I assume that they just receive SIGTERM.</p><p>I am wondering whether the answer is to set up runit&#039;s stage 3 and somehow trigger it at shutdown, early enough that the daemons get the signal before they get a SIGTERM from elsewhere. The sample stage 3 file for Debian Sarge looks like this :-</p><div class="codebox"><pre><code>#!/bin/sh
exec 2&gt;&amp;1

PATH=/command:/sbin:/bin:/usr/sbin:/usr/bin

LAST=0
test -x /etc/runit/reboot &amp;&amp; LAST=6

echo &#039;Waiting for services to stop...&#039;
sv -w196 force-stop /etc/service/*
sv exit /etc/service/*

echo &#039;Shutdown...&#039;
/etc/init.d/rc $LAST</code></pre></div><p>Since runit is not in charge, presumably running /etc/init.d/rc $LAST can be commented out. I also removed /command from the path.<br />Maybe, this stage 3 file could be triggered as K010runit in /etc/rc[06].d to get these daemons to stop cleanly.</p><div class="codebox"><pre><code>cd /etc/rc0.d
ln -s /etc/runit/3 K010runit3
cd /etc/rc6.d
ln -s /etc/runit/3 K010runit3</code></pre></div><p>Also I looked at whether it is possible have runsv catch the SIGTERM and handle it more gracefully. The man page for runsv tells how to customise control signals, so that for SIGTERM :-</p><p>/etc/sv/postfix/control/t could contain :-</p><div class="codebox"><pre><code>#!/bin/sh
echo We have SIGTERM for postfix
/usr/sbin/postfix stop</code></pre></div><p>so this should run for &quot;terminate&quot; and should also pick up the control signals for &quot;down&quot; and &quot;exit&quot;, according to the man page for runsv.</p><p>This does run and appear in /var/svlog/postfix/current when I give the command</p><div class="codebox"><pre><code>sv stop postfix</code></pre></div><p>I reverted the postfix &quot;run&quot; file to the earlier one which uses the &quot;postfix start&quot; command and<br />with stage 3 being called from rc0.d and with control/t set up, then on shutdown I can see in /var/log/syslog :-</p><div class="codebox"><pre><code>Dec  4 10:49:58 fluorine shutdown[4884]: shutting down for system halt
Dec  4 10:49:58 fluorine init: Switching to runlevel: 0
Dec  4 10:49:59 fluorine avahi-daemon[2600]: Got SIGTERM, quitting.
Dec  4 10:49:59 fluorine avahi-daemon[2600]: Leaving mDNS multicast group on interface xenbr0.IPv6 with address fe...
Dec  4 10:49:59 fluorine avahi-daemon[2600]: Leaving mDNS multicast group on interface xenbr0.IPv4 with address 19...
Dec  4 10:49:59 fluorine avahi-daemon[2600]: avahi-daemon 0.6.31 exiting.
Dec  4 10:50:00 fluorine postfix/master[2924]: terminating on signal 15
Dec  4 10:50:00 fluorine ntpd[2466]: ntpd exiting on signal 15
Dec  4 10:50:00 fluorine postfix/postfix-script[5281]: fatal: the Postfix mail system is not running
Dec  4 10:50:00 fluorine postfix/postfix-script[5289]: fatal: the Postfix mail system is not running
Dec  4 10:50:01 fluorine acpid: exiting
Dec  4 10:50:03 fluorine rsyslogd: [origin software=&quot;rsyslogd&quot; swVersion=&quot;8.4.2&quot; x-pid=&quot;2166&quot; x-info=&quot;http://www.rsyslog.com&quot;] exiting on signal 15.</code></pre></div><p>I think that the 2 fatal messages are from &quot;finish&quot; and control/t being called after &quot;master&quot; has alread received SIGTERM, although the echo messages are not appearing in /var/svlogd/postfix/current, maybe svlogd has already been shutdown!</p><p>I can see that before I started trying runit and with postfix being started from SysV init, that on shutdown /var/log/mail.info reports :-</p><div class="codebox"><pre><code>Nov 11 12:23:20 fluorine postfix/master[2909]: terminating on signal 15</code></pre></div><p>So the set up with &quot;runit&quot; seems to produce more or less the same result as with SysV init. Setting up to run stage 3 from rc0.d and also setting up control/t does not appear to have any real effect on shutdown.</p><p>Geoff</p>]]></description>
			<author><![CDATA[dummy@example.com (Geoff 42)]]></author>
			<pubDate>Mon, 04 Dec 2017 15:04:17 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6551#p6551</guid>
		</item>
	</channel>
</rss>
