Sortix
Sortix Download Manual Development Source Code News Blog More
current nightly

Sortix cross-nightly manual

This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.

NAME

service — daemon maintenance

SYNOPSIS

service [-lr] [-s source-daemon] [--exit-code] [--list] [--no-await] [--no-optional] [--raw] [--source=source-daemon] daemon [dependents | disable | edges | enable | exit-code | kill | pid | reconfigure | reload | requirements | restart | signal | start | state | status | stop | terminate]

DESCRIPTION

service performs maintenance of daemons run by init(8) as configured in init(5). The daemons are serviced by connecting to the init process and writing the requested command to the /var/run/init filesytem socket.
The options are as follows:
-s, --source-daemon=source-daemon
When modifying a dependency using the enable, disable, start and stop commands, use the source-daemon as the source daemon in the dependency on the target daemon. The default the local daemon which is the parent of the locally configured daemons.
--exit-code
Set the exit-code flag on the dependency created in the enable and start commands.
--no-await
Set the no-await flag on the dependency created in the enable and start commands.
--no-optional
Unset the optional flag on the dependency created in the enable and start commands. The default is to set the optional flag, which is the opposite of the init(5) require declaration where dependencies are mandatory by default.
-l, --list
Write a table containing the status of every loaded daemon in the format of the status command.
-r, --raw
Write the command and additional operands as a raw message without verification on the init socket and output the raw reply sent from init.
The commands are as follows:
dependents
Write the incoming dependencies on the daemon in the format of the edges command, which explains why a daemon is running.
disable
Permanently disable the daemon by removing the dependency on it from the configuration of the source-daemon (the local daemon by default, see init(5)) and then stopping it using the stop command. The daemon will continue to run if any other daemon depends on it, which can be diagnosed using the dependents command.
edges
Write the incoming dependencies on the daemon and its outgoing dependencies in the format of the require declaration in init(5) with an extra source operand:
require source target [exit-code] [no-await] [optional]
enable
Permanently enable the daemon by adding it to the configuration of the source-daemon (the local daemon by default, see init(5)) with the dependency flags per --exit-code, --no-await, and --no-optional and starting it by sending the start command. The daemon only starts if the source-daemon is running.
exit-code
Write the exit code of the daemon, or the empty string if it has not exited.
kill
Kill the daemon by sending the SIGKILL signal as a last resort that may cause data loss.
pid
Write the process id of the daemon if it is running, or the empty output if it does not have a process. Process ids can be recycled and are subject to inherent race conditions. Prefer to use the other commands in service that addresses the daemon by its symbolic name as init(8) will ensure the command operates on the correct process.
reconfigure
Reread the init(5) configuration for the daemon and apply it after restarting the daemon.
reload
Request the daemon gracefully reload its own configuration sending the reload signal (usually SIGHUP) without restarting the daemon and without reloading the init(5) configuration.
requirements
Write the outgoing dependencies from the daemon in the format of the edges command, which explains what daemons the daemon needs.
restart
Restart the daemon by terminating it and starting it up again afterwards.
signal signal
Send the signal in the symbolic signal name format (e.g. SIGUSR1) to the daemon.
start
Start the daemon by asking init(8) to add a runtime dependency from the source-daemon (the local daemon by default, see init(5)) to the daemon with the dependency flags per --exit-code, --no-await, and --no-optional and starting it by sending the start command. The daemon only starts if the source-daemon is running.
state
Write which the state the daemon is in.
status
Write the status of the daemon as a single table row in the format:
name state pid=pid exit=exit-code
The state is one of terminated, scheduled, waiting, satisfied, starting, running, terminating, finishing, finished, or failed. The pid is the process id if any, or 0 otherwise. The exit-code is the exit code of the daemon if it has exited, or the name of a signal that killed it, or n/a if the daemon has not exited.
stop
Stop the daemon by asking init(8) to remove the dependency from the source-daemon (the local daemon by default, see init(5)) on the daemon. The daemon will continue to run as long if other daemon depends on it, which can be diagnosed using the dependents command.
terminate
Terminate the daemon gracefully by sending the SIGTERM signal and SIGKILL after a timeout. Prefer the stop command if possible as the terminate command bypasses the reference count and may cause data loss if other daemons malfunction when the daemon is unexpectedly terminated.

ENVIRONMENT

INIT_SOCKET
init(8)'s filesystem socket for communication, /var/run/init by default.

FILES

/etc/init/
Daemon configuration for the local system (first in search path) (see init(5))
/etc/init/local
Configuration for the local daemon (see init(5))

EXIT STATUS

service will exit 0 on success and non-zero otherwise.

EXAMPLES

Permanently enable the sshd daemon:
$ service sshd enable
Permanently disable the ntpd daemon:
$ service ntpd disable
Temporarily start the nginx daemon without changing /etc/init/local:
$ service nginx start
Temporarily disable the sshd daemon without changing /etc/init/local:
$ service sshd stop
Temporarily stop the ntpd daemon and diagnose why it kept running due to the time daemon depending on it:
$ service ntpd stop 
$ service ntpd state 
running 
$ service ntpd dependents 
require time ntpd exit-code 
$ service --source-daemon=time ntpd stop 
$ service ntpd state 
finished

SEE ALSO

kill(1), init(5), halt(8), init(8), poweroff(8), reboot(8), shutdown(8)
Copyright 2011-2025 Jonas 'Sortie' Termansen and contributors.
Sortix's source code is free software under the ISC license.
#sortix on irc.sortix.org
@sortix_org