[gentoo-commits] proj/openrc:master commit in: /, man/, sh/, src/rc/

2018-06-15 Thread William Hubbs
commit: e6d01471fe2a8eb8a15bb906d7c91c11805d1bef
Author: William Hubbs  gmail  com>
AuthorDate: Fri Jun 15 17:23:50 2018 +
Commit: William Hubbs  gentoo  org>
CommitDate: Fri Jun 15 17:23:50 2018 +
URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=e6d01471

start-stop-daemon: add ability to log stdout or stderr to processes

 NEWS.md|  9 +
 man/openrc-run.8   | 17 
 man/start-stop-daemon.8| 27 +-
 sh/start-stop-daemon.sh|  2 ++
 src/rc/Makefile|  2 +-
 src/rc/start-stop-daemon.c | 48 ++
 6 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 328247da..13c62d6e 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,6 +4,15 @@ OpenRC NEWS
 This file will contain a list of notable changes for each release. Note
 the information in this file is in reverse order.
 
+## OpenRC 0.37
+
+start-stop-daemon now supports logging stdout and stderr of daemons to
+processes instead of files. These processes are defined by the
+output_logger and error_logger variables in standard service scripts, or
+by the  -3/--output-logger or -4/--error-logger switches if you use
+start-stop-daemon directly. For more information on this, see the
+start-stop-daemon man page.
+
 ## OpenRC 0.36
 
 In this release, the modules-load service has been combined into the

diff --git a/man/openrc-run.8 b/man/openrc-run.8
index f0750406..03f8b680 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -173,6 +173,23 @@ variable is set.
 The same thing as
 .Pa output_log
 but for the standard error output.
+.It Ar output_logger
+This is a process which will be used to log the standard output from the
+service.  If you are starting this service with
+.Xr start-stop-daemon 8 ,
+,  you must set
+.Pa command_background
+to true. Keep in mind that this command must be executable as a shell
+command inside the chroot if the
+.Pa chroot
+variable is set. Keep in mind also that this command works by accepting
+the stdout of the service on stdin.
+An example of a command that can be run this way is logger if you want
+your service output to go to syslog.
+.It Ar error_logger
+The same thing as
+.Pa output_logger
+but for the standard error output.
 .It Ar directory
 .Xr start-stop-daemon 8
 and

diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8
index 706a12ed..ecadb958 100644
--- a/man/start-stop-daemon.8
+++ b/man/start-stop-daemon.8
@@ -131,9 +131,34 @@ Modifies the scheduling priority of the daemon.
 .It Fl 1 , -stdout Ar logfile
 Redirect the standard output of the process to logfile when started with
 .Fl background .
-Must be an absolute pathname, but relative to the path optionally given with
+The logfile Must be an absolute pathname, but relative to the path
+optionally given with
 .Fl r , -chroot .
 The logfile can also be a named pipe.
+.It Fl 2 , -stderr Ar logfile
+Redirect the standard error of the process to logfile when started with
+.Fl background .
+The logfile must be an absolute pathname, but relative to the path
+optionally given with
+.Fl r , -chroot .
+The logfile can also be a named pipe.
+.It Fl 3 , -stdout-logger Ar cmd
+Run cmd as a child process redirecting the standard output to the
+standard input of cmd when started with
+.Fl background .
+Cmd must be an absolute pathname, but relative to the path optionally given 
with
+.Fl r , -chroot .
+This process must be prepared to accept input on stdin and be able to
+log it or send it to another location.
+.It Fl 4 , -stderr-logger Ar cmd
+Run cmd as a child process and 
+Redirect the standard error of the process to the standard input of cmd
+when started with
+.Fl background .
+Cmd must be an absolute pathname, but relative to the path optionally given 
with
+.Fl r , -chroot .
+This process must be prepared to accept input on stdin and be able to
+log it or send it to another location.
 .It Fl w , -wait Ar milliseconds
 Wait
 .Ar milliseconds

diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh
index 35c642c0..69666ff7 100644
--- a/sh/start-stop-daemon.sh
+++ b/sh/start-stop-daemon.sh
@@ -47,6 +47,8 @@ ssd_start()
${directory:+--chdir} $directory \
${output_log+--stdout} $output_log \
${error_log+--stderr} $error_log \
+   ${output_logger+--stdout-logger} \"$output_logger\" \
+   ${error_logger+--stderr-logger} \"$error_logger\" \
${procname:+--name} $procname \
${pidfile:+--pidfile} $pidfile \
${command_user+--user} $command_user \

diff --git a/src/rc/Makefile b/src/rc/Makefile
index 4b0983b5..b09c5058 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -158,7 +158,7 @@ rc-service: rc-service.o _usage.o rc-misc.o
 rc-update: rc-update.o _usage.o rc-misc.o
${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ 
${LDADD}
 
-st

[gentoo-commits] proj/openrc:master commit in: man/, sh/

2016-09-16 Thread William Hubbs
commit: c146b966913ae80652e3be925d3aba60ed82f14d
Author: William Hubbs  gmail  com>
AuthorDate: Fri Sep 16 19:23:09 2016 +
Commit: William Hubbs  gentoo  org>
CommitDate: Fri Sep 16 19:23:09 2016 +
URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c146b966

Add command_progress variable

If this is set to yes, 1, true, or on, start-stop-daemon will display a
progress meter while waiting for a daemon to stop.

 man/openrc-run.8| 4 
 sh/start-stop-daemon.sh | 5 -
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/man/openrc-run.8 b/man/openrc-run.8
index 6e3b9dc..5ec8156 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -143,6 +143,10 @@ Set this to "true", "yes" or "1" (case-insensitive) if you 
want
 .Xr start-stop-daemon 8
 to force the daemon into the background. This forces the
 "--make-pidfile" and "--pidfile" options, so the pidfile variable must be set.
+.It Ar command_progress
+Set this to "true", "yes" or "1" (case-insensitive) if you want 
+.Xr start-stop-daemon 8
+to display a progress meter when waiting for a daemon to stop.
 .It Ar command_user
 If the daemon does not support changing to a different user id, you can
 use this to change the user id before

diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh
index 6b679ac..6f396b3 100644
--- a/sh/start-stop-daemon.sh
+++ b/sh/start-stop-daemon.sh
@@ -63,6 +63,7 @@ ssd_start()
 
 ssd_stop()
 {
+   local _progress=
local startcommand="$(service_get_value "command")"
local startchroot="$(service_get_value "chroot")"
local startpidfile="$(service_get_value "pidfile")"
@@ -72,13 +73,15 @@ ssd_stop()
pidfile="${startpidfile:-$pidfile}"
procname="${startprocname:-$procname}"
[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
+   yesno "${command_progress}" && _progress=--progress
ebegin "Stopping ${name:-$RC_SVCNAME}"
start-stop-daemon --stop \
${retry:+--retry} $retry \
${command:+--exec} $command \
${procname:+--name} $procname \
${pidfile:+--pidfile} $chroot$pidfile \
-   ${stopsig:+--signal} $stopsig
+   ${stopsig:+--signal} $stopsig \
+   ${_progress}
 
eend $? "Failed to stop ${name:-$RC_SVCNAME}"
 }



[gentoo-commits] proj/openrc:master commit in: man/, /, sh/, init.d/

2015-05-11 Thread William Hubbs
commit: bb2d7becfd3008379f8f69b5d036922281aa211f
Author: William Hubbs  gmail  com>
AuthorDate: Mon May 11 23:07:28 2015 +
Commit: William Hubbs  gentoo  org>
CommitDate: Mon May 11 23:36:49 2015 +
URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=bb2d7bec

Add support for the s6 supervision suite

 init.d/Makefile |  2 +-
 init.d/s6-svscan.in | 31 +
 man/openrc-run.8| 12 
 s6-guide.md | 56 +
 sh/Makefile |  2 +-
 sh/openrc-run.sh.in |  4 
 sh/s6.sh| 46 +++
 7 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/init.d/Makefile b/init.d/Makefile
index 0bd3651..a662f8d 100644
--- a/init.d/Makefile
+++ b/init.d/Makefile
@@ -3,7 +3,7 @@ include ../mk/net.mk
 DIR=   ${INITDIR}
 SRCS=  bootmisc.in fsck.in hostname.in local.in localmount.in loopback.in \
netmount.in osclock.in root.in savecache.in swap.in swapfiles.in \
-   tmpfiles.setup.in swclock.in sysctl.in urandom.in ${SRCS-${OS}}
+   tmpfiles.setup.in swclock.in sysctl.in urandom.in s6-svscan.in 
${SRCS-${OS}}
 BIN=   ${OBJS}
 
 # Are we installing our network scripts?

diff --git a/init.d/s6-svscan.in b/init.d/s6-svscan.in
new file mode 100644
index 000..6fdf4e1
--- /dev/null
+++ b/init.d/s6-svscan.in
@@ -0,0 +1,31 @@
+#!@SBINDIR@/openrc-run
+# Copyright (C) 2015 William Hubbs 
+# Released under the 2-clause BSD license.
+
+command=/bin/s6-svscan
+command_args="${RC_SVCDIR}"/s6-scan
+command_background=yes
+pidfile=/var/run/s6-svscan.pid
+
+depend()
+{
+   need localmount
+}
+
+start_pre()
+{
+   einfo "Creating s6 scan directory"
+   checkpath -d -m 0755 "$RC_SVCDIR"/s6-scan
+   return $?
+}
+
+stop_post()
+{
+   ebegin "Stopping any remaining s6 services"
+   s6-svc -dx "${RC_SVCDIR}"/s6-scan/* 2>/dev/null || true
+   eend $?
+
+   ebegin "Stopping any remaining s6 service loggers"
+   s6-svc -dx "${RC_SVCDIR}"/s6-scan/*/log 2>/dev/null || true
+   eend $?
+}

diff --git a/man/openrc-run.8 b/man/openrc-run.8
index f144152..259d23f 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -107,6 +107,18 @@ the service has already been stopped.
 String describing the service.
 .It Ar description_$command
 String describing the extra command.
+.It Ar supervisor
+Supervisor to use to monitor this daemon. If this is unset,
+start-stop-daemon will be used. The only alternate supervisor we support
+in this release is S6 from Skarnet software. To use this, set
+supervisor=s6.
+.It Ar s6_service_path
+The path to the s6 service directory if you are monitoring this service
+with S6. The default is /etc/svc.d/${RC_SVCNAME}.
+.It Ar s6_svwait_options_start
+The options to pass to s6-svwait when starting the service via s6.
+.It Ar s6_svwait_options_stop
+The options to pass to s6-svwait when stopping the service via s6.
 .It Ar start_stop_daemon_args
 List of arguments passed to start-stop-daemon when starting the daemon.
 .It Ar command

diff --git a/s6-guide.md b/s6-guide.md
new file mode 100644
index 000..4a37a9c
--- /dev/null
+++ b/s6-guide.md
@@ -0,0 +1,56 @@
+# Using S6 with OpenRC
+
+Beginning with OpenRC-0.16, we support using the s6 supervision suite
+from Skarmet Software in place of start-stop-daemon for monitoring
+daemons [1].
+
+## Setup
+
+Documenting s6 in detail is beyond the scope of this guide. It will
+document how to set up OpenRC services to communicate with s6.
+
+### 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.
+
+### Dependencies
+
+All OpenRC service scripts that want their daemons monitored by s6
+should have the following line added to their dependencies to make sure
+the s6 scan directory is being monitored.
+
+need s6-svscan
+
+### Variable Settings
+
+The most important setting is the supervisor variable. At the top of
+your service script, you should set this variable as follows:
+
+supervisor=s6
+
+Several other variables affect s6 services. They are documented on the
+openrc-run man page, but I will list them here for convenience:
+
+s6_service_path - the path to the s6 service directory
+s6_svwait_options_start - the options to pass to s6-svwait when starting
+s6_svwait_options_stop - the options to pass to s6-svwait when stopping.
+
+The s6_service_path variable defaults to /etc/svc.d/${RC_SVCNAME} if it
+is not set in the service script. For example, if you want a service
+script called /etc/init.d/foobar to use s6 to monitor its daemon, the s6
+service should be the directory /etc/svc.d/foobar.
+
+See the documentation for s6 for more information about s6 service
+directories.
+
+The s6_svwait_options_* variables set command line options to pass to
+s6-svwait when starting or stopping the s6 serv