From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/456 Path: main.gmane.org!not-for-mail From: Gerrit Pape Newsgroups: gmane.comp.sysutils.supervision.general Subject: initiate reboot in stage 1 (Re: the rest of sysvinit) Date: Sun, 20 Jun 2004 12:42:08 +0000 Message-ID: <20040620124224.9316.qmail@c8d9f1ebecf122.315fe32.mid.smarden.org> References: <40A53477.2010501@geeks.cl> <20040514220510.19494.qmail@4d20e0ca3c6480.315fe32.mid.smarden.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" X-Trace: sea.gmane.org 1087735334 7333 80.91.224.253 (20 Jun 2004 12:42:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 20 Jun 2004 12:42:14 +0000 (UTC) Original-X-From: supervision-return-694-gcsg-supervision=m.gmane.org@list.skarnet.org Sun Jun 20 14:42:05 2004 Return-path: Original-Received: from antah.skarnet.org ([212.85.147.14]) by deer.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 1Bc1e9-0007QE-00 for ; Sun, 20 Jun 2004 14:42:05 +0200 Original-Received: (qmail 3574 invoked by uid 76); 20 Jun 2004 12:42:26 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 3569 invoked from network); 20 Jun 2004 12:42:26 -0000 Original-To: supervision@list.skarnet.org Mail-Followup-To: supervision@list.skarnet.org Content-Disposition: inline In-Reply-To: <20040514220510.19494.qmail@4d20e0ca3c6480.315fe32.mid.smarden.org> Xref: main.gmane.org gmane.comp.sysutils.supervision.general:456 X-Report-Spam: http://spam.gmane.org/gmane.comp.sysutils.supervision.general:456 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, May 14, 2004 at 10:06:27PM +0000, Gerrit Pape wrote: > On Fri, May 14, 2004 at 05:04:55PM -0400, Alejandro Mery wrote: > > iirc you posted once a shutdown replacement, is it available somewhere? > > It was a reboot command, but you need this only if you want to tell the > kernel to reboot in stage 1, use with care > http://article.gmane.org/gmane.comp.sysutils.supervision.general/315 Hi, I plan to make the following changes to the runit program, please see the attached patch. If stage 1 crashes or exits 100, stage 2 will be skipped; if stage 2 crashes or exits 111, it will be restarted. This should eliminate the need for such a reboot program, see the updated runit man page. Regards, Gerrit. --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff Index: doc/runit.8.html =================================================================== RCS file: /var/lib/cvs/runit/doc/runit.8.html,v retrieving revision 1.16 diff -u -r1.16 runit.8.html --- doc/runit.8.html 28 Mar 2004 18:31:17 -0000 1.16 +++ doc/runit.8.html 20 Jun 2004 12:08:23 -0000 @@ -15,46 +15,46 @@

Description

runit must be run as Unix process no 1. It performs the system’s booting, running, and shutdown -in three Stages: +in three stages:

Stage 1

runit runs /etc/runit/1 and waits for it to terminate. The system’s one time tasks are done here. /etc/runit/1 has full control of /dev/console to be able to start an emergency shell if the one time -initialization tasks fail. If /etc/runit/1 itself crashes, runit will skip -stage 2 and enter stage 3. +initialization tasks fail. If /etc/runit/1 crashes, or exits 100, runit +will skip stage 2 and enter stage 3.

Stage 2

-runit runs /etc/runit/2, which should -not return until system shutdown; if it crashes, it will be restarted. Normally -/etc/runit/2 starts runsvdir(8). runit is able to handle the ctrl-alt-del -keyboard request in Stage 2, see below. +runit runs /etc/runit/2, which +should not return until system shutdown; if it crashes, or exits 111, it +will be restarted. Normally /etc/runit/2 starts runsvdir(8). runit is able +to handle the ctrl-alt-del keyboard request in stage 2, see below.

Stage 3

-If runit is told to shutdown -the system, or the Stage 2 returns without errors, it terminates Stage -2 if it is running, and runs /etc/runit/3. The systems tasks to shutdown -and halt or reboot are done here. If Stage 3 returns, runit checks if the -file /etc/runit/reboot exists and has the execute by owner permission set. -If so, the system is rebooted, it’s halted otherwise. +If +runit is told to shutdown the system, or stage 2 returns, it terminates +stage 2 if it is running, and runs /etc/runit/3. The systems tasks to shutdown +and possibly halt or reboot the system are done here. If stage 3 returns, +runit checks if the file /etc/runit/reboot exists and has the execute by +owner permission set. If so, the system is rebooted, it’s halted otherwise. +

Ctrl-alt-del

-If runit -receives the ctrl-alt-del keyboard request and the file /etc/runit/ctrlaltdel -exists and has the execute by owner permission set, runit runs /etc/runit/ctrlaltdel, -waits for it to terminate, and then sends itself a CONT signal. +If runit receives the ctrl-alt-del keyboard request and the file +/etc/runit/ctrlaltdel exists and has the execute by owner permission set, +runit runs /etc/runit/ctrlaltdel, waits for it to terminate, and then sends +itself a CONT signal.

Signals

-runit -only accepts signals in Stage 2.

-If runit receives a CONT signal and the -file /etc/runit/stopit exists and has the execute by owner permission set, -runit is told to shutdown the system.

-if runit receives an INT signal, a -ctrl-alt-del keyboard request is triggered. +runit only accepts signals in stage 2.

+If runit +receives a CONT signal and the file /etc/runit/stopit exists and has the +execute by owner permission set, runit is told to shutdown the system.

+if +runit receives an INT signal, a ctrl-alt-del keyboard request is triggered. +

See Also

-runit-init(8), runsvdir(8), -runsvchdir(8), utmpset(8), runsv(8), runsvctrl(8), runsvstat(8), chpst(8), -svlogd(8), svwaitdown(8), svwaitup(8)

+runit-init(8), runsvdir(8), runsvchdir(8), utmpset(8), runsv(8), +runsvctrl(8), runsvstat(8), chpst(8), svlogd(8), svwaitdown(8), svwaitup(8) +

http://smarden.org/runit/

Author

-Gerrit -Pape <pape@smarden.org>

+Gerrit Pape <pape@smarden.org>


Table of Contents

Index: man/runit.8 =================================================================== RCS file: /var/lib/cvs/runit/man/runit.8,v retrieving revision 1.13 diff -u -r1.13 runit.8 --- man/runit.8 28 Mar 2004 18:17:13 -0000 1.13 +++ man/runit.8 20 Jun 2004 12:08:25 -0000 @@ -6,7 +6,7 @@ .SH DESCRIPTION .B runit must be run as Unix process no 1. -It performs the system's booting, running, and shutdown in three Stages: +It performs the system's booting, running, and shutdown in three stages: .SH STAGE 1 .B runit runs @@ -19,29 +19,30 @@ to be able to start an emergency shell if the one time initialization tasks fail. If .I /etc/runit/1 -itself crashes, +crashes, or exits 100, .B runit will skip stage 2 and enter stage 3. .SH STAGE 2 .B runit runs .IR /etc/runit/2 , -which should not return until system shutdown; if it crashes, it will be -restarted. +which should not return until system shutdown; if it crashes, or exits 111, +it will be restarted. Normally .I /etc/runit/2 starts .BR runsvdir (8). .B runit -is able to handle the ctrl-alt-del keyboard request in Stage 2, see below. +is able to handle the ctrl-alt-del keyboard request in stage 2, see below. .SH STAGE 3 If .B runit -is told to shutdown the system, or the Stage 2 returns without errors, it -terminates Stage 2 if it is running, and runs +is told to shutdown the system, or stage 2 returns, it terminates stage 2 if +it is running, and runs .IR /etc/runit/3 . -The systems tasks to shutdown and halt or reboot are done here. -If Stage 3 returns, +The systems tasks to shutdown and possibly halt or reboot the system are +done here. +If stage 3 returns, .B runit checks if the file .I /etc/runit/reboot @@ -59,7 +60,7 @@ waits for it to terminate, and then sends itself a CONT signal. .SH SIGNALS .B runit -only accepts signals in Stage 2. +only accepts signals in stage 2. .P If .B runit Index: src/runit.c =================================================================== RCS file: /var/lib/cvs/runit/src/runit.c,v retrieving revision 1.11 diff -u -r1.11 runit.c --- src/runit.c 28 Oct 2003 12:06:22 -0000 1.11 +++ src/runit.c 20 Jun 2004 12:08:26 -0000 @@ -168,27 +168,28 @@ if (child == pid) { if (wait_exitcode(wstat) != 0) { - if (wait_crashed(wstat)) { + if (wait_crashed(wstat)) strerr_warn3(WARNING, "child crashed: ", stage[st], 0); - if (st == 0) { - /* this is stage 1 */ + else + strerr_warn3(WARNING, "child failed: ", stage[st], 0); + if (st == 0) + /* this is stage 1 */ + if (wait_crashed(wstat) || (wait_exitcode(wstat) == 100)) { strerr_warn3(INFO, "leave stage: ", stage[st], 0); strerr_warn2(WARNING, "skipping stage 2...", 0); st++; break; } - } - else - strerr_warn3(WARNING, "child failed: ", stage[st], 0); - if (st == 1) { + if (st == 1) /* this is stage 2 */ - strerr_warn2(WARNING, "killing all processes in stage 2...", 0); - kill(-pid, 9); - sleep(5); - strerr_warn2(WARNING, "restarting.", 0); - st--; - break; - } + if (wait_crashed(wstat) || (wait_exitcode(wstat) == 111)) { + strerr_warn2(WARNING, "killing all processes in stage 2...", 0); + kill(-pid, 9); + sleep(5); + strerr_warn2(WARNING, "restarting.", 0); + st--; + break; + } } strerr_warn3(INFO, "leave stage: ", stage[st], 0); break; --SUOF0GtieIMvvwua--