s6-rc: the s6-rc-db program
Keywords: s6-rc offline database dump command rc init dependency state management services

s6-rc
Software
skarnet.org

# The s6-rc-db program

s6-rc-db is a tool to analyze a compiled service database and extract information from it, and print it in a user-friendly format.

It is an offline tool, i.e. you can run it on any compiled service database without actually having a live set of services managed by s6-rc. However, if you do have a live set, you can still run s6-rc-db on the current database (and it is the default); it won't interfere with your normal service operation.

## Interface

         s6-rc-db help
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] check
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] list all|services|oneshots|longruns|bundles
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] type servicename
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] [ -u | -d ] timeout atomicname
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] contents bundlename
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] [ -u | -d ] dependencies servicename
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] pipeline longrunname
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] [ -u | -d ] script oneshotname
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] flags atomicname
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] atomics servicename...
         s6-rc-db [ -l live ] [ -c compiled ] [ -b ] [ -u | -d ] all-dependencies servicename...

- s6-rc-db expects to find a compiled service database in compiled; by default it uses the service database used by the live state in live. It reads and parses the compiled database it finds; depending on its arguments, it prints the requested information to stdout, then exits 0.

## Options

- `-c compiled` : examine a compiled service database in compiled instead of the current live one.
- `-l live` : assume the live state is in live. This option is ignored if the `-c` option has been given. Default is `/run/s6-rc`. The default can be changed at package compilation time, by giving the `--livedir=live` option to `./configure`.
- `-u` : for commands that use different data depending on whether it's about bringing the service up or down, select the "up" data (this is the default). This option is ignored when it is irrelevant.
- `-d` : for commands that use different data depending on whether it's about bringing the service up or down, select the "down" data. This option is ignored when it is irrelevant.
- `-b` : blocking lock. If the database is currently being used by another program, s6-rc-db will wait until that other program has released its lock on the database, then proceed. By default, s6-rc-db fails with an error message if the database is currently in use.

## Exit codes

- 0: success
- 3: identifier not found in service database
- 4: invalid or corrupted service database
- 5: wrong identifier type for the given command
- 100: wrong usage
- 111: system call failed

## Subcommands

### s6-rc-db help

Prints a help message on stdout.

### s6-rc-db check

Checks the database consistency. Exits 4 with an error message if it finds a problem, such as a mismatch in the direct and reverse dependency tables, or a dependency cycle.

### s6-rc-db list

Lists all services of a given type. This subcommand takes a second subcommand:

#### s6-rc-db list all

Lists everything - atomic services and bundles - contained in the database.

#### s6-rc-db list services

Lists all atomic services.

#### s6-rc-db list oneshots

Lists oneshots.

#### s6-rc-db list longruns

Lists longruns.

#### s6-rc-db list bundles

Lists all bundles.

### s6-rc-db type servicename

Prints the type of servicename: `oneshot`, `longrun` or `bundle`.

### s6-rc-db timeout atomicname

Prints the timeout value, in milliseconds, after which bringing atomicname up or down is considered a failure if the called script still has not succeeded. By default, or if the `-u` option has been given to s6-rc-db, the timeout for up is printed; the timeout for down is printed instead if the `-d` option has been given.

### s6-rc-db contents bundlename

Lists the atomic services represented by bundle bundlename.

### s6-rc-db dependencies servicename

Prints the list of direct dependencies for servicename. If servicename is a bundle, its set of direct dependencies is the union of the direct dependencies of all the atomic services contained in the bundle.

If the `-d` option has been given to s6-rc-db, the reverse dependencies are given instead: services that directly depend on servicename, or on one of its components if it is a bundle.

### s6-rc-db pipeline longrunname

Prints the longrun service pipeline longrunname is a part of, one producer/consumer pair by line. Producers and consumers are separated by a slash. If longrunname isn't part of a pipeline, only longrunname is printed.

### s6-rc-db script oneshotname

Prints the up script for oneshotname, which is an argv, i.e. a Unix command line. Each component of this command line is terminated by a null character, so to print it in a human-readable format, pipe the output into something like `xargs -0 echo`.

If the `-d` option has been given to s6-rc-db, the down script is printed instead.

### s6-rc-db flags atomicname

Prints a hexadecimal number that is the list of all binary flags for atomic service atomicname.

Those binary flags are used by repo commands:

- Bit 0 is set if there's a `flag-essential` file in the source directory (or if the "essential" flag was inherited from a bundle). It means the service cannot be downed by normal means: `s6-rc -d change atomicname` will not work, the `-D` option to s6-rc is needed. Additionally, when importing atomicname in a set, it will automatically be put in the `always` rx, which means it will always be enabled by default.
- Bit 1 is set if there's a `flag-recommended` file in the source directory (or if the "recommended" flag was inherited from a bundle). When importing atomicname in a set, it will automatically be put in the `active` rx rather than the `latent` one: unless the user actively makes a change before committing the set, atomicname will be in the default bundle and be started at boot time.

### s6-rc-db atomics servicename...

Prints the fully resolved list of services represented by the servicename... arguments, i.e. the union of all atomic services contained in servicename.... Each argument in servicename... can be an atomic service or a bundle.

### s6-rc-db all-dependencies servicename...

Prints the list of all atomic services needed to bring up all of the servicename... arguments, with all their dependencies, recursively. In other words: for servicename... to be up, every single service listed in the output will need to be up. The output includes the atomic services represented by the servicename... arguments themselves.

The list is not topologically sorted.

If the `-d` option has been given to s6-rc-db, the recursive list of reverse dependencies is printed: for servicename... to be down, every single service listed in the output will need to be down.