13e2ea4ccSMatthew Dillon.\" 23e2ea4ccSMatthew Dillon.\" Copyright (c) 2014 33e2ea4ccSMatthew Dillon.\" The DragonFly Project. All rights reserved. 43e2ea4ccSMatthew Dillon.\" 53e2ea4ccSMatthew Dillon.\" Redistribution and use in source and binary forms, with or without 63e2ea4ccSMatthew Dillon.\" modification, are permitted provided that the following conditions 73e2ea4ccSMatthew Dillon.\" are met: 83e2ea4ccSMatthew Dillon.\" 93e2ea4ccSMatthew Dillon.\" 1. Redistributions of source code must retain the above copyright 103e2ea4ccSMatthew Dillon.\" notice, this list of conditions and the following disclaimer. 113e2ea4ccSMatthew Dillon.\" 2. Redistributions in binary form must reproduce the above copyright 123e2ea4ccSMatthew Dillon.\" notice, this list of conditions and the following disclaimer in 133e2ea4ccSMatthew Dillon.\" the documentation and/or other materials provided with the 143e2ea4ccSMatthew Dillon.\" distribution. 153e2ea4ccSMatthew Dillon.\" 3. Neither the name of The DragonFly Project nor the names of its 163e2ea4ccSMatthew Dillon.\" contributors may be used to endorse or promote products derived 173e2ea4ccSMatthew Dillon.\" from this software without specific, prior written permission. 183e2ea4ccSMatthew Dillon.\" 193e2ea4ccSMatthew Dillon.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 203e2ea4ccSMatthew Dillon.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 213e2ea4ccSMatthew Dillon.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 223e2ea4ccSMatthew Dillon.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 233e2ea4ccSMatthew Dillon.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 243e2ea4ccSMatthew Dillon.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 253e2ea4ccSMatthew Dillon.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 263e2ea4ccSMatthew Dillon.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 273e2ea4ccSMatthew Dillon.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 283e2ea4ccSMatthew Dillon.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 293e2ea4ccSMatthew Dillon.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 303e2ea4ccSMatthew Dillon.\" SUCH DAMAGE. 313e2ea4ccSMatthew Dillon.\" 323e2ea4ccSMatthew Dillon.Dd November 10, 2014 3321537d46SMatthew Dillon.Dt SVC 8 343e2ea4ccSMatthew Dillon.Os 353e2ea4ccSMatthew Dillon.Sh NAME 3621537d46SMatthew Dillon.Nm svc 373e2ea4ccSMatthew Dillon.Nd build an environment and monitor/maintain a service or command 383e2ea4ccSMatthew Dillon.Sh SYNOPSIS 393e2ea4ccSMatthew Dillon.Nm 403e2ea4ccSMatthew Dillon.Op Fl options 413e2ea4ccSMatthew Dillon.Ar directive 423e2ea4ccSMatthew Dillon.Ar label 433e2ea4ccSMatthew Dillon.Op arguments-to-directive 443e2ea4ccSMatthew Dillon.Sh DESCRIPTION 453e2ea4ccSMatthew Dillon.Nm 463e2ea4ccSMatthew Dillonis a program which can build, monitor, and manage a simple environment 473e2ea4ccSMatthew Dillonand execute a command within that environment. 483e2ea4ccSMatthew DillonIt uses the 49*3917a8afSSascha Wildner.Xr procctl 2 503e2ea4ccSMatthew Dillonsystem call to round-up all processes and sub-processes created under the 513e2ea4ccSMatthew Dillonenvironment. 523e2ea4ccSMatthew DillonIt can detect when the specific command or the command and all processes 533e2ea4ccSMatthew Dillonexit and perform some action, and it can do a few relatively simple support 543e2ea4ccSMatthew Dillonfunctions to terminate, restart, or terminate/re-initiate. 553e2ea4ccSMatthew Dillon.Pp 563e2ea4ccSMatthew DillonThe following options are available: 573e2ea4ccSMatthew Dillon.Bl -tag -width indent 583e2ea4ccSMatthew Dillon.It Fl d 593e2ea4ccSMatthew DillonDebug mode. Additional debug output is printed. 603e2ea4ccSMatthew DillonThis will also force 613e2ea4ccSMatthew Dillon.Fl f . 623e2ea4ccSMatthew Dillon.It Fl f 633e2ea4ccSMatthew DillonForeground mode. Instead of fork/detaching the service, the service itself 643e2ea4ccSMatthew Dillonruns in the foreground when the 653e2ea4ccSMatthew Dillon.Ar init 663e2ea4ccSMatthew Dillondirective is specified. The pid will not be printed in this case. 67ee6361d4SMatthew Dillon.It Fl h 68ee6361d4SMatthew DillonDisplay quick help for directives and exit. 693e2ea4ccSMatthew Dillon.It Fl p Ar directory 703e2ea4ccSMatthew DillonSpecify the directory to store pidfiles and sockets in, and to search 713e2ea4ccSMatthew Dillonfor active labels. 723e2ea4ccSMatthew DillonIf not specified, the default is 733e2ea4ccSMatthew Dillon.Pa /var/run . 743e2ea4ccSMatthew DillonIf specified as 753e2ea4ccSMatthew Dillon.Ar none , 763e2ea4ccSMatthew Dillonno pidfile will be created or maintained. The 773e2ea4ccSMatthew Dillon.Ar none 783e2ea4ccSMatthew Dillonspecification is not recommended except in combination with 793e2ea4ccSMatthew Dillon.Fl f 803e2ea4ccSMatthew Dillon.Fl x . 813e2ea4ccSMatthew Dillon.It Fl r Ar timo 823e2ea4ccSMatthew DillonSpecify the restart delay and enable automatic restarts if the original 833e2ea4ccSMatthew Dilloncommand under management exits, even if other processes are still present. 843e2ea4ccSMatthew DillonThis option also modifies the behavior of the 853e2ea4ccSMatthew Dillon.Ar stop 863e2ea4ccSMatthew Dillonservice command, causing it to kill only the main process under management. 873e2ea4ccSMatthew DillonAny forked children will be left intact. 883e2ea4ccSMatthew DillonThis option is exclusive with 893e2ea4ccSMatthew Dillon.Fl R . 903e2ea4ccSMatthew Dillon.It Fl R Ar timo 913e2ea4ccSMatthew DillonSpecify the restart delay and enable automatic restarts if all processes 923e2ea4ccSMatthew Dillonunder management exit. 933e2ea4ccSMatthew DillonThis option also modifies the behavior of the 943e2ea4ccSMatthew Dillon.Ar stop 953e2ea4ccSMatthew Dillonservice command, causing it to kill all processes under management. 963e2ea4ccSMatthew DillonThis option is exclusive with 973e2ea4ccSMatthew Dillon.Fl r . 983e2ea4ccSMatthew Dillon.It Fl x 993e2ea4ccSMatthew DillonCauses the service demon itself to exit if the service being monitored 1003e2ea4ccSMatthew Dillonexits or is stopped. 1013e2ea4ccSMatthew DillonSpecify as an option to the left of the 1023e2ea4ccSMatthew Dillon.Ar init 1033e2ea4ccSMatthew Dillondirective. 1043e2ea4ccSMatthew Dillon.Nm 1053e2ea4ccSMatthew Dillonwill still use 1063e2ea4ccSMatthew Dillon.Fl r 1073e2ea4ccSMatthew Dillonor 1083e2ea4ccSMatthew Dillon.Fl R 1093e2ea4ccSMatthew Dillonto indicate what is considered a dead service (some or all of the processes). 1103e2ea4ccSMatthew DillonIf neither is specified, 1113e2ea4ccSMatthew Dillon.Fl r 1123e2ea4ccSMatthew Dillonis assumed. If specified, the timeout is irrelevant as there will be no 1133e2ea4ccSMatthew Dillonrestart. 1143e2ea4ccSMatthew Dillon.Pp 1153e2ea4ccSMatthew DillonThis option also issues a 1163e2ea4ccSMatthew Dillon.Ar stopall 1173e2ea4ccSMatthew Dillondirective before exiting. That is, it will still ensure that all processes 1183e2ea4ccSMatthew Dillonrunning under the service, either direct or indirect, are dead before the 1193e2ea4ccSMatthew Dillonservice itself exits. 1203e2ea4ccSMatthew Dillon.It Fl s 1213e2ea4ccSMatthew DillonCauses the service demon to issue a 1223e2ea4ccSMatthew Dillon.Xr sync 2 1233e2ea4ccSMatthew Dilloncommand after stopping or killing a service. 1243e2ea4ccSMatthew Dillon.It Fl t Ar timo 1253e2ea4ccSMatthew DillonWhen stopping processes under management, specify the amount of time 1263e2ea4ccSMatthew Dillonallowed to elapse after sending a SIGTERM before sending a SIGKILL. 1273e2ea4ccSMatthew DillonIf 0 is specified, only SIGKILL will be sent. 1283e2ea4ccSMatthew DillonThe default is 10 seconds. 1293e2ea4ccSMatthew Dillon.It Fl u Ar user 13021537d46SMatthew DillonSet the uid and gid of the command to execute based on the user. 13121537d46SMatthew DillonThe uid or username must exist in the password file. 13221537d46SMatthew DillonThe gid may be overridden by the 13321537d46SMatthew Dillon.Fl g 13421537d46SMatthew Dillonor 13521537d46SMatthew Dillon.Fl G 13621537d46SMatthew Dillonoptions. 13721537d46SMatthew DillonThe service demon itself is not affected. 1383e2ea4ccSMatthew Dillon.Pp 1393e2ea4ccSMatthew DillonSpecified when initializing a new service, has no effect for other directives. 1403e2ea4ccSMatthew DillonCannot be overridden in 1413e2ea4ccSMatthew Dillon.Ar start 1423e2ea4ccSMatthew Dillonor 1433e2ea4ccSMatthew Dillon.Ar restart . 1443e2ea4ccSMatthew Dillon.It Fl g Ar group 14521537d46SMatthew DillonSet the gid of the command to execute. 14621537d46SMatthew DillonThis will override the user's gid set via the 14721537d46SMatthew Dillon.Fl u 14821537d46SMatthew Dillonoption. 14921537d46SMatthew DillonThe service demon itself is not affected. 1503e2ea4ccSMatthew Dillon.Pp 1513e2ea4ccSMatthew DillonSpecified when initializing a new service, has no effect for other directives. 1523e2ea4ccSMatthew DillonCannot be overridden in 1533e2ea4ccSMatthew Dillon.Ar start 1543e2ea4ccSMatthew Dillonor 1553e2ea4ccSMatthew Dillon.Ar restart . 1563e2ea4ccSMatthew Dillon.It Fl G Ar group-list 1573e2ea4ccSMatthew DillonSet the group-list of the command to execute. The service demon itself is not 1583e2ea4ccSMatthew Dillonaffected. 15921537d46SMatthew DillonThis will completely override all other assumed or specified GIDs. 1603e2ea4ccSMatthew Dillon.Pp 1613e2ea4ccSMatthew DillonSpecified when initializing a new service, has no effect for other directives. 1623e2ea4ccSMatthew DillonCannot be overridden in 1633e2ea4ccSMatthew Dillon.Ar start 1643e2ea4ccSMatthew Dillonor 1653e2ea4ccSMatthew Dillon.Ar restart . 1663e2ea4ccSMatthew Dillon.It Fl l Ar path 1673e2ea4ccSMatthew DillonSet the logfile path for the command. 1683e2ea4ccSMatthew DillonIf not specified, no logfile will be created. 1693e2ea4ccSMatthew DillonHowever, the service monitor will still keep track of the last ~8KB or 1703e2ea4ccSMatthew Dillonso of stdout/stderr output. 1713e2ea4ccSMatthew Dillon.Pp 1723e2ea4ccSMatthew DillonSpecified when initializing a new service, has no effect for other directives. 17321537d46SMatthew Dillon.It Fl m 17421537d46SMatthew DillonMay be used in combination with 17521537d46SMatthew Dillon.Fl c 17621537d46SMatthew Dillonor 17721537d46SMatthew Dillon.Fl j 17821537d46SMatthew Dillonto automatically mount /dev in a chroot or jail. 17921537d46SMatthew DillonIt will be left mounted through stops and starts and will be unmounted 18021537d46SMatthew Dillonwhen 18121537d46SMatthew Dillon.Nm 18221537d46SMatthew Dillonis told to exit. 18321537d46SMatthew Dillon.Pp 18421537d46SMatthew DillonSpecified when initializing a new service, has no effect for other directives. 1853e2ea4ccSMatthew Dillon.It Fl c Ar directory 1863e2ea4ccSMatthew DillonChroot into the specified directory when executing or re-executing the 1873e2ea4ccSMatthew Dilloncommand. The service itself stays outside the chroot. 18821537d46SMatthew DillonIf 18921537d46SMatthew Dillon.Fl m 19021537d46SMatthew Dillonis also specified, the service will automatically mount /dev in the chroot 19121537d46SMatthew Dillonif it does not already exist and unmount it when the service exits. The 19221537d46SMatthew Dillonmount remains in place when the service is stopped. 1933e2ea4ccSMatthew Dillon.Pp 1943e2ea4ccSMatthew DillonSpecified when initializing a new service, has no effect for other directives. 1953e2ea4ccSMatthew DillonCannot be overridden in 1963e2ea4ccSMatthew Dillon.Ar start 1973e2ea4ccSMatthew Dillonor 1983e2ea4ccSMatthew Dillon.Ar restart . 1993e2ea4ccSMatthew Dillon.It Fl j Ar directory 2003e2ea4ccSMatthew DillonCreate a jail and operate in a manner similar to a chroot. 2013e2ea4ccSMatthew Dillon.It Fl k Ar jail-spec 2023e2ea4ccSMatthew DillonAdditional specification for the jail. See below. 2033e2ea4ccSMatthew Dillon.It Fl T Ar title 2043e2ea4ccSMatthew DillonTell 2053e2ea4ccSMatthew Dillon.Nm 2063e2ea4ccSMatthew Dillonto use 207*3917a8afSSascha Wildner.Xr setproctitle 3 2083e2ea4ccSMatthew Dillonto adjust what shows up in a ps command, to make process lists easier to 2093e2ea4ccSMatthew Dillondiagnose. 2103e2ea4ccSMatthew Dillon.It Fl F Ar restarts:pertimo 2113e2ea4ccSMatthew DillonSpecify failure timing. 2123e2ea4ccSMatthew DillonIf a service is automatically restarted more than the specified number 2133e2ea4ccSMatthew Dillonwithin the specified period, the service is considered to be in a failed 2143e2ea4ccSMatthew Dillonstate when it next dies and will no longer be restarted. 2153e2ea4ccSMatthew Dillon.Pp 2163e2ea4ccSMatthew DillonThe situation will be syslogged and an email will be sent to 2173e2ea4ccSMatthew Dillon.Ar service-errors 2183e2ea4ccSMatthew Dillonwith a description of the problem if the service is running as root. 2193e2ea4ccSMatthew DillonIf the service is running as a user, the email is sent to the user. 2203e2ea4ccSMatthew DillonThe system operator should generally setup a mail alias to point 2213e2ea4ccSMatthew Dillon.Ar service-errors 2223e2ea4ccSMatthew Dillonto the desired destination. 2233e2ea4ccSMatthew Dillon.Pp 2243e2ea4ccSMatthew DillonThis feature is disabled by default. 2253e2ea4ccSMatthew DillonIf you only specify the restart count the rate will default to 2263e2ea4ccSMatthew Dillonper 60 seconds. 2273e2ea4ccSMatthew DillonSpecify as an option to the left of the 2283e2ea4ccSMatthew Dillon.Ar init 2293e2ea4ccSMatthew Dillondirective. 2303e2ea4ccSMatthew Dillon.It Ar directive Op arguments-to-directive 2313e2ea4ccSMatthew DillonSpecify a directive (see below). 2323e2ea4ccSMatthew Dillon.It Ar label 2333e2ea4ccSMatthew DillonSpecify a label to name or locate the service. 2343e2ea4ccSMatthew DillonNote that most directives allow a label prefix to be specified, affecting 2353e2ea4ccSMatthew Dillonmultiple services. 2363e2ea4ccSMatthew DillonIf your label is postfixed by a number, you should use a fixed-width 2373e2ea4ccSMatthew Dillon0-fill field for the number or risk some confusion. 2383e2ea4ccSMatthew Dillon.El 2393e2ea4ccSMatthew Dillon.Pp 2403e2ea4ccSMatthew DillonAll timeouts and delays are specified in seconds. 2413e2ea4ccSMatthew Dillon.Pp 2423e2ea4ccSMatthew DillonIf neither 2433e2ea4ccSMatthew Dillon.Fl r 2443e2ea4ccSMatthew Dillonor 2453e2ea4ccSMatthew Dillon.Fl R 2463e2ea4ccSMatthew Dillonis specified in the 2473e2ea4ccSMatthew Dillon.Ar init 2483e2ea4ccSMatthew Dillondirective, the service will not automatically restart if the underlying 2493e2ea4ccSMatthew Dillonprocesses exit. The service demon will remain intact unless 2503e2ea4ccSMatthew Dillon.Fl x 2513e2ea4ccSMatthew Dillonhas been specified. 2523e2ea4ccSMatthew Dillon.Pp 2533e2ea4ccSMatthew Dillon.Nm 2543e2ea4ccSMatthew Dillonalways creates a pid file in the pid directory named 2553e2ea4ccSMatthew Dillon.Pa service.<label>.pid 2563e2ea4ccSMatthew Dillonand maintains an open descriptor with an active exclusive 2573e2ea4ccSMatthew Dillon.Xr flock 2 2583e2ea4ccSMatthew Dillonon the file. 2593e2ea4ccSMatthew DillonScripts can determine whether the service demon itself is running or not 2603e2ea4ccSMatthew Dillonvia the 2613e2ea4ccSMatthew Dillon.Xr lockf 1 2623e2ea4ccSMatthew Dillonutility, or may use the convenient 2633e2ea4ccSMatthew Dillon.Ar status 2643e2ea4ccSMatthew Dillondirective and check the exit code to get more detailed status. 2653e2ea4ccSMatthew DillonIn addition, a service socket is created in the pid directory named 2663e2ea4ccSMatthew Dillon.Pa service.<label>.sk 2673e2ea4ccSMatthew Dillonwhich 2683e2ea4ccSMatthew Dillon.Nm 2693e2ea4ccSMatthew Dillonuses to communicate with a running service demon. 2703e2ea4ccSMatthew Dillon.Pp 2713e2ea4ccSMatthew DillonNote that the service demon itself will not exit when the executed command 2723e2ea4ccSMatthew Dillonexits unless you have used the 2733e2ea4ccSMatthew Dillon.Fl x 2743e2ea4ccSMatthew Dillonoption, or the 2753e2ea4ccSMatthew Dillon.Ar exit 2763e2ea4ccSMatthew Dillonor 2773e2ea4ccSMatthew Dillon.Ar kill 2783e2ea4ccSMatthew Dillondirectives. 2793e2ea4ccSMatthew Dillon.Pp 2803e2ea4ccSMatthew DillonSome RC services, such as sendmail, may maintain multiple service processes 2813e2ea4ccSMatthew Dillonand name each one with a postfix to the label. 2823e2ea4ccSMatthew DillonBy specifying just the prefix, your directives will affect all matching 2833e2ea4ccSMatthew Dillonlabels. 2843e2ea4ccSMatthew Dillon.Pp 2853e2ea4ccSMatthew DillonFor build systems the 2863e2ea4ccSMatthew Dillon.Fl x 2873e2ea4ccSMatthew Dillonoption is typically used, sometimes with the 2883e2ea4ccSMatthew Dillon.Fl f 2893e2ea4ccSMatthew Dillonoption, and allowed to default to just waiting for the original command 2903e2ea4ccSMatthew Dillonexec to exit. 2913e2ea4ccSMatthew DillonThis will cause the service demon to then kill any remaining hanger-ons 2923e2ea4ccSMatthew Dillonbefore exiting. 2933e2ea4ccSMatthew Dillon.Sh DIRECTIVES 2943e2ea4ccSMatthew Dillon.Bl -tag -width indent 295ee6361d4SMatthew Dillon.It Ar init Ar label Ar exec-command Op arguments 2963e2ea4ccSMatthew DillonStart a new service with the specified label. 2973e2ea4ccSMatthew DillonThis command will fail if the label is already in-use. 2983e2ea4ccSMatthew DillonThis command will detach a new service demon, create a pidfile, and 2993e2ea4ccSMatthew Dillonoutput the pid of the new service demon to stdout before returning. 3003e2ea4ccSMatthew Dillon.Pp 3013e2ea4ccSMatthew DillonIf the 3023e2ea4ccSMatthew Dillon.Ar exec-command 3033e2ea4ccSMatthew Dillonis a single word and not an absolute or relative path, the system 3043e2ea4ccSMatthew Dilloncommand path will be searched for the command. 3053e2ea4ccSMatthew Dillon.It Ar start 3063e2ea4ccSMatthew DillonStart a service that has been stopped. 3073e2ea4ccSMatthew DillonThe label can be a wildcard prefix so, for example, if there are 3083e2ea4ccSMatthew Dillonthree sendmail services (sendmail01, sendmail02, sendmail03), then 3093e2ea4ccSMatthew Dillonthe label 'sendmail' will operate on all three. 3103e2ea4ccSMatthew Dillon.Pp 3113e2ea4ccSMatthew DillonIf the service is already running, this directive will be a NOP. 3123e2ea4ccSMatthew Dillon.It Ar stop 3133e2ea4ccSMatthew DillonStop a running service by sending a TERM signal and later a KILL signal 3143e2ea4ccSMatthew Dillonif necessry, to some or all processes 3153e2ea4ccSMatthew Dillonrunning under the service. The processes signaled depend on the original 3163e2ea4ccSMatthew Dillon.Fl r 3173e2ea4ccSMatthew Dillonor 3183e2ea4ccSMatthew Dillon.Fl R 3193e2ea4ccSMatthew Dillonoptions specified when the service was initiated. 3203e2ea4ccSMatthew DillonThese options, along with 3213e2ea4ccSMatthew Dillon.Fl t 3223e2ea4ccSMatthew Dillonmay also be specified in this directive to override 3233e2ea4ccSMatthew Dillon(but not permanently change) the original options. 3243e2ea4ccSMatthew Dillon.Pp 3253e2ea4ccSMatthew DillonThe service demon itself remains intact. 3263e2ea4ccSMatthew Dillon.It Ar stopall 3273e2ea4ccSMatthew DillonThis is a short-hand for 3283e2ea4ccSMatthew Dillon.Fl R Ar 0 3293e2ea4ccSMatthew Dillon.Ar stop . 3303e2ea4ccSMatthew DillonIt will kill all sub-processes of the service regardless of whether 3313e2ea4ccSMatthew Dillon.Fl r 3323e2ea4ccSMatthew Dillonor 3333e2ea4ccSMatthew Dillon.Fl R 3343e2ea4ccSMatthew Dillonwas used in the original 3353e2ea4ccSMatthew Dillon.Ar init 3363e2ea4ccSMatthew Dillondirective. 3373e2ea4ccSMatthew Dillon.It Ar restart 3383e2ea4ccSMatthew DillonExecute the 3393e2ea4ccSMatthew Dillon.Ar stop 3403e2ea4ccSMatthew Dillonoperation, sleep for a few seconds based on the original 3413e2ea4ccSMatthew Dillon.Fl r 3423e2ea4ccSMatthew Dillonor 3433e2ea4ccSMatthew Dillon.Fl R 3443e2ea4ccSMatthew Dillonoptions, and then execute the 3453e2ea4ccSMatthew Dillon.Ar start 3463e2ea4ccSMatthew Dillonoperation. 3473e2ea4ccSMatthew DillonThese options, along with 3483e2ea4ccSMatthew Dillon.Fl t 3493e2ea4ccSMatthew Dillonmay also be specified in this directive to override 3503e2ea4ccSMatthew Dillon(but not permanently change) the original options. 3513e2ea4ccSMatthew Dillon.It Ar exit 3523e2ea4ccSMatthew DillonExecute the 3533e2ea4ccSMatthew Dillon.Ar stop 3543e2ea4ccSMatthew Dillonoperation but override prior options and terminate ALL processes 3553e2ea4ccSMatthew Dillonrunning under the service. 3563e2ea4ccSMatthew DillonThe service demon itself then terminates and must be init'd again 3573e2ea4ccSMatthew Dillonto restart. 358ee6361d4SMatthew Dillon.Pp 359ee6361d4SMatthew DillonThis function will also remove any stale pid and socket files. 3603e2ea4ccSMatthew Dillon.It Ar kill 3613e2ea4ccSMatthew DillonExecute the 3623e2ea4ccSMatthew Dillon.Ar stop 3633e2ea4ccSMatthew Dillonoperation but override prior options and terminate ALL processes 3643e2ea4ccSMatthew Dillonrunning under the service. 3653e2ea4ccSMatthew DillonAlso force the delay to 0, bypassing SIGTERM and causing SIGKILL to be 3663e2ea4ccSMatthew Dillonsent. 3673e2ea4ccSMatthew DillonThe service demon itself then terminates and must be init'd again 3683e2ea4ccSMatthew Dillonto restart. 369ee6361d4SMatthew Dillon.Pp 370ee6361d4SMatthew DillonThis function will also remove any stale pid and socket files. 3713e2ea4ccSMatthew Dillon.It Ar list 3723e2ea4ccSMatthew DillonList a subset of labels and their status. 3733e2ea4ccSMatthew DillonIf no label is specified, all active labels are listed. 3743e2ea4ccSMatthew Dillon.It Ar status 3753e2ea4ccSMatthew DillonPrint the status of a particular label, exit with a 0 status if 3763e2ea4ccSMatthew Dillonthe service exists and is still considered to be running. 3773e2ea4ccSMatthew DillonExit with 1 if the service exists but is considered to be stopped. 3783e2ea4ccSMatthew DillonExit with 2 if the service does not exist. 3793e2ea4ccSMatthew DillonIf multiple labels match, the worst condition found becomes the exit code. 3803e2ea4ccSMatthew Dillon.Pp 3813e2ea4ccSMatthew DillonScripts that use this feature can conveniently use the 3823e2ea4ccSMatthew Dillon.Ar start 3833e2ea4ccSMatthew Dillondirective to start any matching service that is considered stopped. 3843e2ea4ccSMatthew DillonThe directive is a NOP for services that are considered to be running. 3853e2ea4ccSMatthew Dillon.It Ar log 3863e2ea4ccSMatthew DillonThe service demon monitors stdout/stderr output from programs it runs 3873e2ea4ccSMatthew Dilloncontinuously and will remember the last ~8KB or so, which can be 3883e2ea4ccSMatthew Dillondumped via this directive. 3893e2ea4ccSMatthew Dillon.It Ar logf 3903e2ea4ccSMatthew DillonThis works the same as 3913e2ea4ccSMatthew Dillon.Ar log 3923e2ea4ccSMatthew Dillonbut continues to monitor and dump the output until you ^C. 3933e2ea4ccSMatthew DillonIn order to avoid potentially stalling the service under management, 3943e2ea4ccSMatthew Dillongaps may occur if the monitor is unable to keep up with the log 3953e2ea4ccSMatthew Dillonoutput. 3963e2ea4ccSMatthew Dillon.It Ar tailf 3973e2ea4ccSMatthew DillonThis works similarly to 3983e2ea4ccSMatthew Dillon.Ar logf 3993e2ea4ccSMatthew Dillonbut dumps fewer lines of log history before dovetailing into 4003e2ea4ccSMatthew Dilloncontinuous monitoring. 401ee6361d4SMatthew Dillon.It Ar logfile Ar label Op path 4023e2ea4ccSMatthew DillonRe-open, set, or change the logfile path for the monitor, 4033e2ea4ccSMatthew Dilloncreating a new logfile if necessary. 4043e2ea4ccSMatthew DillonThe logfile is created by the parent monitor (the one not running in 4053e2ea4ccSMatthew Dillona chroot or jail or as a particular user or group). 4063e2ea4ccSMatthew DillonThis way the service under management cannot modify or destroy it. 4073e2ea4ccSMatthew Dillon.Pp 4083e2ea4ccSMatthew DillonIt is highly recommended that you specify an absolute path when 4093e2ea4ccSMatthew Dillonchanging the logfile. 4103e2ea4ccSMatthew DillonIf you wish to disable the logfile, set it to /dev/null. 4113e2ea4ccSMatthew DillonDisabling the logfile does not prevent you from viewing the 4123e2ea4ccSMatthew Dillonlast ~8KB and/or monitoring any logged data. 413ee6361d4SMatthew Dillon.It Ar help 414ee6361d4SMatthew DillonDisplay quick help for directives. 4153e2ea4ccSMatthew Dillon.El 4163e2ea4ccSMatthew Dillon.Pp 4173e2ea4ccSMatthew DillonDescription of nominal operation 418*3917a8afSSascha Wildner.Xr procctl 2 4193e2ea4ccSMatthew Dillonsystem call. 4203e2ea4ccSMatthew Dillon.Sh JAIL-SPECIFICATIONS 4213e2ea4ccSMatthew DillonA simple jail just chroots into a directory, possibly mounts /dev, and 4223e2ea4ccSMatthew Dillonallows all current IP bindings to be used. 4233e2ea4ccSMatthew DillonThe service demon itself does not run in the jail, but will keep the 4243e2ea4ccSMatthew Dillonjail intact across 4253e2ea4ccSMatthew Dillon.Ar stop 4263e2ea4ccSMatthew Dillonand 4273e2ea4ccSMatthew Dillon.Ar start/restart 4283e2ea4ccSMatthew Dillonoperations by leaving a forked process intact inside. 4293e2ea4ccSMatthew DillonIf the jail is destroyed, the service demon will re-create it if necessary 4303e2ea4ccSMatthew Dillonon a 4313e2ea4ccSMatthew Dillon.Ar start/restart . 4323e2ea4ccSMatthew Dillon.Fl k 4333e2ea4ccSMatthew Dillonoption may be used to specify additional parameters. 4343e2ea4ccSMatthew DillonParameters are comma-delimited with no spaces. 4353e2ea4ccSMatthew DillonValues may be specified in the name=value format. 4363e2ea4ccSMatthew DillonFor example: 4373e2ea4ccSMatthew Dillon.Fl k Ar clean,ip=1.2.3.4,ip=5.6.7.8 4383e2ea4ccSMatthew Dillon.Bl -tag -width indent 4393e2ea4ccSMatthew Dillon.It Ar clean 4403e2ea4ccSMatthew DillonThe jail is handed a clean environment, similar to what 4413e2ea4ccSMatthew Dillon.Xr jail 8 4423e2ea4ccSMatthew Dillondoes. 4433e2ea4ccSMatthew Dillon.It Ar ip=addr 4443e2ea4ccSMatthew DillonThe jail is allowed to bind to the specified IP address. This option may 4453e2ea4ccSMatthew Dillonbe specified multiple times. 4463e2ea4ccSMatthew Dillon.El 4473e2ea4ccSMatthew Dillon.Sh SIGNALS 4483e2ea4ccSMatthew DillonGenerally speaking signals should not be sent to a service demon. 4493e2ea4ccSMatthew DillonInstead, the command should be run with an appropriate directive to 4503e2ea4ccSMatthew Dillonadjust running behavior. 4513e2ea4ccSMatthew DillonHowever, the service demon will act on signals as follows: 4523e2ea4ccSMatthew Dillon.Bl -tag -width indent 4533e2ea4ccSMatthew Dillon.It Dv SIGTERM 4543e2ea4ccSMatthew DillonThe service demon will execute the 4553e2ea4ccSMatthew Dillon.Ar exit 4563e2ea4ccSMatthew Dillondirective. 4573e2ea4ccSMatthew Dillon.It Dv SIGHUP 4583e2ea4ccSMatthew DillonThe service demon will execute the 4593e2ea4ccSMatthew Dillon.Ar restart 4603e2ea4ccSMatthew Dillondirective. 4613e2ea4ccSMatthew Dillon.El 4623e2ea4ccSMatthew Dillon.Sh HISTORY 4633e2ea4ccSMatthew DillonThe 4643e2ea4ccSMatthew Dillon.Nm 4653e2ea4ccSMatthew Dillonutility first appeared in 4663e2ea4ccSMatthew Dillon.Dx 4.0 . 467