Skip to content

Conversation

@roberth
Copy link

@roberth roberth commented Apr 15, 2022

Goals:

  • support systemd-style socket activated child services (half of Support systemd's socket activation FD passing #1)
  • have a module
  • make configurable via config file
  • support zero downtime service updates in the module (needs the config file for mutation)
  • support zero downtime environment variable changes
  • more tests
    • what if the new service doesn't start?
    • what if the old service doesn't terminate by itself?
  • make the test socket server terminate on HUP

# Avoid automatic restarts. This will trigger a reload instead.
reloadIfChanged = true;
serviceConfig.ExecStart = [
"${systemConfig.socketmaster.package}/bin/socketmaster -command ${lib.escapeShellArg config.command} -start ${toString config.startMillis} -listen fd://3"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"${systemConfig.socketmaster.package}/bin/socketmaster -command ${lib.escapeShellArg config.command} -start ${toString config.startMillis} -listen fd://3"
"${systemConfig.socketmaster.package}/bin/socketmaster -command /run/socketmaster/${config.name} -start ${toString config.startMillis} -listen fd://3"

If I'm not mistaken the command needs to point to a mutable location so that on reload, it would load the new command.

As an aside, the command script might also include a bunch of env vars.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured this could be covered by an entry in a config file instead. Not dissimilar to a systemd unit file, but far more limited, because we can't change many of those fancy settings like security or mounts related ones once the systemd service is running.

@roberth roberth changed the title NixOS synergy NixOS synergy + hot swap May 19, 2022
systemAttrs = eachDefaultSystem perSystem;

in
systemAttrs // flakeAttrs;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me of flake-parts :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants