files.rc

Service name/command and its configuration

  • {name}.bundle for bundles
  • {name}.oneshot for one shot activations scripts
  • {name}.longrun for deamons services

All services are disabled by default.

It will fail at activation time if:

  • More then onde type (bundle, oneshot, longrun) were defined for the same {name}
  • One dependency service ins't defined but required

type

attribute set of (submodule)

example

{
  files.rc = {
    hello = {
      enable = true;
      longrun = {
        run = "mySquirelD";
      };
    };
    hola = {
      bundle = {
        contents = [
          "hello"
          "world"
        ];
      };
      enable = true;
    };
    world = {
      enable = true;
      oneshot = {
        setup = "echo Hello World > $PRJ_DATA_DIR/hello.txt";
      };
    };
  };
}

default

{
  files.rc = { };
}

files.rc.<name>.enable

Enable this service

type

boolean

example

{
  files.rc.<name>.enable = true;
}

default

{
  files.rc.<name>.enable = false;
}

files.rc.<name>.bundle

bundle is a service aggregator

For example we can bundle every system (db, http, config) by microservice.

Like:

  • Commerce Bundle:
    • commerce database service
    • commerce api service
    • commerce cache service
  • BPMN Bundle
    • BPMN database service
    • BPMN api service
    • BPMN cache service

type

null or (submodule)

example

{
  files.rc.<name>.bundle = {
    contents = [
      "myFancyServiceName"
    ];
    essential = true;
  };
}

default

{
  files.rc.<name>.bundle = null;
}

files.rc.<name>.bundle.deps

Defines what makes part of this bundle

type

non-empty (list of non-empty string)

example

{
  files.rc.<name>.bundle.deps = [
    "myDep"
    "myOtherDep"
  ];
}

files.rc.<name>.bundle.essential

Mark this bundle and all its dependencies as essential

It means some commands may work to stop these services

type

boolean

example

{
  files.rc.<name>.bundle.essential = true;
}

default

{
  files.rc.<name>.bundle.essential = false;
}

files.rc.<name>.longrun

longrun are commands that run as deamon (in a infinity loop).

Applications:

  • static site service
  • test watcher
  • some script to warn that your coffe bottle is empty

type

null or (submodule)

example

{
  files.rc.<name>.longrun = {
    agreement = {
      description = "Check to confirm";
      label = "Are you sure?";
    };
  };
}

default

{
  files.rc.<name>.longrun = null;
}

files.rc.<name>.longrun.consumer-for

Defines names of other services this services expects receive data at stdin from theirs stdout

Dependency hierarchy are calculated at activation time.

See S6 documentation for more info

type

list of non-empty string

example

{
  files.rc.<name>.longrun.consumer-for = [
    "myService"
  ];
}

default

{
  files.rc.<name>.longrun.consumer-for = [ ];
}

files.rc.<name>.longrun.data

Path that contains data for your service

type

null or path

example

{
  files.rc.<name>.longrun.data = "./.data";
}

default

{
  files.rc.<name>.longrun.data = null;
}

files.rc.<name>.longrun.deps

Defines names of other services required to be ready to this service work.

Dependency hierarchy are calculated at activation time.

See S6 documentation for more info

type

list of non-empty string

example

{
  files.rc.<name>.longrun.deps = [
    "myDependency"
  ];
}

default

{
  files.rc.<name>.longrun.deps = [ ];
}

files.rc.<name>.longrun.env

Path that contains env data for your service

type

null or path

example

{
  files.rc.<name>.longrun.env = "./.direnv";
}

default

{
  files.rc.<name>.longrun.env = null;
}

files.rc.<name>.longrun.essential

Mark this service and all its dependencies as essential

It means some commands may work to stop this service

type

boolean

example

{
  files.rc.<name>.longrun.essential = true;
}

default

{
  files.rc.<name>.longrun.essential = false;
}

files.rc.<name>.longrun.kill-after

Time in ms to give up from this service shutdown process and kill it anyway.

  • 0 means never

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.kill-after = 2005;
}

default

{
  files.rc.<name>.longrun.kill-after = 0;
}

files.rc.<name>.longrun.kill-finish-after

Time in ms to give up from this service finish script and kill it.

  • 0 means never

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.kill-finish-after = 2005;
}

default

{
  files.rc.<name>.longrun.kill-finish-after = 0;
}

files.rc.<name>.longrun.lock-descriptor

Configure a file descriptor to show that service is running

If value any value other then 0, 1 or 2, this service uses file-descriptor lock

type

null or unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.lock-descriptor = 5;
}

default

{
  files.rc.<name>.longrun.lock-descriptor = 0;
}

files.rc.<name>.longrun.max-restarts

Times it should restart before we giveup

  • Could not be more than 4096

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.max-restarts = 2005;
}

default

{
  files.rc.<name>.longrun.max-restarts = 100;
}

files.rc.<name>.longrun.pipeline-name

Define name of this pipeline.

Dependency hierarchy are calculated at activation time.

See S6 documentation for more info

type

null or non-empty string

example

{
  files.rc.<name>.longrun.pipeline-name = "logMyService";
}

default

{
  files.rc.<name>.longrun.pipeline-name = null;
}

files.rc.<name>.longrun.producer-for

Defines a service to read this progam stdout (ie a logger)

Dependency hierarchy are calculated at activation time.

See S6 documentation for more info

type

null or non-empty string

example

{
  files.rc.<name>.longrun.producer-for = "willReadMyLog";
}

default

{
  files.rc.<name>.longrun.producer-for = null;
}

files.rc.<name>.longrun.readiness

Configure it to use pooling script as ready notification method

It make your service start script be called with s6-notifyoncheck.

See also ready-descriptor.

type

null or (submodule)

example

{
  files.rc.<name>.longrun.readiness = {
    command = "curl https://localhost";
  };
}

default

{
  files.rc.<name>.longrun.readiness = null;
}

files.rc.<name>.longrun.readiness.attempts

Times it should run before give up from this service

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.readiness.attempts = 30;
}

default

{
  files.rc.<name>.longrun.readiness.attempts = 7;
}

files.rc.<name>.longrun.readiness.command

Command to be executed as checking method

If not defined {name}-ready is assumed to be command to run

type

null or non-empty string

example

{
  files.rc.<name>.longrun.readiness.command = "curl -sSf http://localhost:8080";
}

default

{
  files.rc.<name>.longrun.readiness.command = null;
}

files.rc.<name>.longrun.readiness.fork-fork

If the check script should double fork

type

boolean

example

{
  files.rc.<name>.longrun.readiness.fork-fork = true;
}

default

{
  files.rc.<name>.longrun.readiness.fork-fork = false;
}

files.rc.<name>.longrun.readiness.initial-delay

Time in ms to await and check if its ready

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.readiness.initial-delay = 10;
}

default

{
  files.rc.<name>.longrun.readiness.initial-delay = 50;
}

files.rc.<name>.longrun.readiness.interval

Time in ms between check attempts

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.readiness.interval = 1000;
}

default

{
  files.rc.<name>.longrun.readiness.interval = 100;
}

files.rc.<name>.longrun.readiness.timeout

Time in ms to give up from this service

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.readiness.timeout = 3000;
}

default

{
  files.rc.<name>.longrun.readiness.timeout = 2000;
}

files.rc.<name>.longrun.ready-descriptor

Configure how to check if this service ready notification method

If value any value other then 0, 1 or 2, this service uses file-descriptor notification method

If attr readiness is defined, use pooling as notification method

type

null or unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.ready-descriptor = 3;
}

default

{
  files.rc.<name>.longrun.ready-descriptor = null;
}

files.rc.<name>.longrun.signal

Signal service expects to init down process

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.signal = 3;
}

default

{
  files.rc.<name>.longrun.signal = 15;
}

files.rc.<name>.longrun.start

' execline setup script.

If not defined {name}-start is assumed to be command to run

Example for non execline scripts:

```nix
files.rc.alo.oneshot.start =
# creates a python script to run when srv start
# and save it at nix store
let start = pkgs.writeScript "mySrvStartScript" 
''
  #!/usr/bin/env -S python
  print("Alô!")  # is hello in portuguese
'';
# use the nix store address
in "${start}";
```</para>

type

null or non-empty string

example

{
  files.rc.<name>.longrun.start = "mysqld";
}

default

{
  files.rc.<name>.longrun.start = null;
}

files.rc.<name>.longrun.stop

execline teardown script.

If not defined {name}-stop is assumed to be command to run

Example for non execline scripts:

files.rc.alo.oneshot.stop = 
# creates a python script to run when srv stop
# and save it at nix store
let stop = pkgs.writeScript "mySrvStopScript"
''
  #!/usr/bin/env -S bash
  echo "Tchau!"  # is bye in portuguese
'';
# use the nix store address
in "${stop}";
```</para>

#### type

null or non-empty string

#### example

```nix
{
  files.rc.<name>.longrun.stop = "abSUrDO kill -9 1 1";
}

default

{
  files.rc.<name>.longrun.stop = null;
}

files.rc.<name>.longrun.timeout

This service should be ready in X milliseconds or it will considered a failure transition.

If null or 0 system will wait indefinitely

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.timeout = 10000;
}

default

{
  files.rc.<name>.longrun.timeout = 0;
}

files.rc.<name>.longrun.timeout-down

This service should be stoped in X milliseconds or it will considered a failure transition.

If null or 0 system will wait indefinitely

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.longrun.timeout-down = 10000;
}

default

{
  files.rc.<name>.longrun.timeout-down = 0;
}

files.rc.<name>.oneshot

oneshot is a change in the system state

Applications examples:

  • start other service that aren't controlled by this environment
  • mount files
  • sync sources

type

null or (submodule)

example

{
  files.rc.<name>.oneshot = {
    dependencies = [
      "holyMoses"
    ];
    setup = {
      example = "echo Hello World > $PRJ_DATA_DIR/hello.txt";
    };
    timeout = 2000;
  };
}

default

{
  files.rc.<name>.oneshot = null;
}

files.rc.<name>.oneshot.deps

Defines names of other services required to be ready to this service work.

Dependency hierarchy are calculated at activation time.

type

list of non-empty string

example

{
  files.rc.<name>.oneshot.deps = [
    "myDependency"
  ];
}

default

{
  files.rc.<name>.oneshot.deps = [ ];
}

files.rc.<name>.oneshot.essential

Mark this service and all its dependencies as essential

It means some commands may work to stop these services

type

boolean

example

{
  files.rc.<name>.oneshot.essential = true;
}

default

{
  files.rc.<name>.oneshot.essential = false;
}

files.rc.<name>.oneshot.start

execline setup script.

If not defined {name}-start is assumed to be command to run

Example for non execline scripts:

files.rc.alo.oneshot.start =
# creates a python script to run when srv start
# and save it at nix store
let start = pkgs.writeScript "mySrvStartScript" 
''
  #!/usr/bin/env -S python
  print("Alô!")  # is hello in portuguese
'';
# use the nix store address
in "${start}";
```</para>

#### type

null or non-empty string

#### example

```nix
{
  files.rc.<name>.oneshot.start = "echo Hello World > $PRJ_DATA_DIR/hello.txt";
}

default

{
  files.rc.<name>.oneshot.start = null;
}

files.rc.<name>.oneshot.stop

execline teardown script.

If not defined {name}-stop is assumed to be command to run

Example for non execline scripts:

files.rc.alo.oneshot.stop = 
# creates a python script to run when srv stop
# and save it at nix store
let stop = pkgs.writeScript "mySrvStopScript"
''
  #!/usr/bin/env -S bash
  echo "Tchau!"  # is bye in portuguese
'';
# use the nix store address
in "${stop}";
```</para>

#### type

null or non-empty string

#### example

```nix
{
  files.rc.<name>.oneshot.stop = "rm $PRJ_DATA_DIR/hello.txt";
}

default

{
  files.rc.<name>.oneshot.stop = null;
}

files.rc.<name>.oneshot.timeout

This service should be ready in X milliseconds or it will considered be in failure status.

If null or 0 system will wait indefinitely

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.oneshot.timeout = 10000;
}

default

{
  files.rc.<name>.oneshot.timeout = 0;
}

files.rc.<name>.oneshot.timeout-down

This service should be stop in X milliseconds or it will considered be in failure status.

If null or 0 system will wait indefinitely

type

unsigned integer, meaning >=0

example

{
  files.rc.<name>.oneshot.timeout-down = 10000;
}

default

{
  files.rc.<name>.oneshot.timeout-down = 0;
}