NAME

Svsh - Process supervision shell for daemontools/perp/s6/runit (base class)

SYNOPSIS

package Svsh::SomeSupervisor;

use Moo;
use namespace::clean;

with 'Svsh';

# implement required methods

DESCRIPTION

svsh is a shell for process supervision suites of the daemontools family, including perp, s6 and runit. Refer to svsh for documentation of the shell itself. This file documents the base class for Svsh adapter classes.

ATTRIBUTES

basedir

Required, Read-Only.

The base directory from which the process supervisor is managing services.

bindir

Read-Only.

The directory where the process supervisor's tools are located. Any call to the supervisor's tools will be prefixed with this path if provided. For usage in case the tools are not in the running user's PATH environment variable.

collapse

Read-Write.

A boolean indicating whether the collapse option should be enabled.

statuses

Read-Only.

A hash-ref of services and their statuses (this is automatically populated by the respective status() method in the adapter classes. For every service, a hash-ref with status, duration and pid keys should exist.

REQUIRED METHODS

status()

Finds all services managed by the supervisor, and populates the statuses attribute.

start( @services )

Starts a list of services if they are down.

stop( @services )

Stops a list of services (should not restart them).

restart( @services )

Stops and starts a list of services. Generally, this is implemented with a QUIT signal to the services, but check with the specific adapter class.

signal( $signal, @services )

Sends UNIX signal to a list of services.

fg( $service )

Finds the log file to which a service is writing, and displays it on screen with the tail -f command.

WANTED METHODS

These methods are not required by adapter classes. If they are not implemented, they will be unavailable in the shell.

rescan()

Causes the supervisor to rescan the service directory to find new or removed services.

terminate()

Terminates the supervisor. Should also terminate all running services.

METHODS

run_cmd( $cmd, [ @args ] )

Runs a shell command with zero or more arguments and returns its output. If the bindir attribute is set, and the $cmd is one of the supervision suite's library of tools, $cmd will be prefixed with bindir.

find_logfile( $pid )

Finds the log file into which a logging program is currently writing to. $pid is the process ID of the logging program. Currently, tinylog, s6-log, svlogd and multilog are supported.

Returns undef if the file is not found.

BUGS AND LIMITATIONS

Please report any bugs or feature requests to https://github.com/ido50/Svsh/issues.

AUTHOR

Ido Perlmuter <ido@ido50.net>

Thanks to the guys at the supervision mailing list, especially Colin Booth, for helping out with suggestions and information.

LICENSE AND COPYRIGHT

Copyright (c) 2015-2023, Ido Perlmuter ido@ido50.net.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.