Fix reload for services without reload functionality.
This commit is contained in:
parent
9ddb6340d9
commit
1454525760
4 changed files with 63 additions and 18 deletions
|
|
@ -6,8 +6,44 @@
|
|||
let
|
||||
forEachUbuntuImage = lib.flip lib.mapAttrs' system-manager.lib.images.ubuntu.${system};
|
||||
|
||||
# To test reload and restart, we include two services, one that can be reloaded
|
||||
# and one that cannot.
|
||||
# The id parameter is a string that can be used to force reloading the services
|
||||
# between two configs by changing their contents.
|
||||
testModule = id: { lib, pkgs, ... }: {
|
||||
systemd.services = {
|
||||
has-reload = {
|
||||
enable = true;
|
||||
description = "service-reload";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecReload = ''
|
||||
${lib.getBin pkgs.coreutils}/bin/true
|
||||
'';
|
||||
};
|
||||
wantedBy = [ "system-manager.target" ];
|
||||
script = ''
|
||||
echo "I can be reloaded (id: ${id})"
|
||||
'';
|
||||
};
|
||||
has-no-reload = {
|
||||
enable = true;
|
||||
description = "service-no-reload";
|
||||
serviceConfig.Type = "simple";
|
||||
wantedBy = [ "system-manager.target" ];
|
||||
script = ''
|
||||
while true; do
|
||||
echo "I cannot be reloaded (id: ${id})"
|
||||
done
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
newConfig = system-manager.lib.makeSystemConfig {
|
||||
modules = [
|
||||
(testModule "new")
|
||||
({ lib, pkgs, ... }: {
|
||||
config = {
|
||||
nixpkgs.hostPlatform = system;
|
||||
|
|
@ -22,18 +58,20 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
systemd.services.new-service = {
|
||||
enable = true;
|
||||
description = "new-service";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecReload = "${lib.getBin pkgs.coreutils}/bin/true";
|
||||
systemd.services = {
|
||||
new-service = {
|
||||
enable = true;
|
||||
description = "new-service";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecReload = "${lib.getBin pkgs.coreutils}/bin/true";
|
||||
};
|
||||
wantedBy = [ "system-manager.target" "default.target" ];
|
||||
script = ''
|
||||
sleep 2
|
||||
'';
|
||||
};
|
||||
wantedBy = [ "system-manager.target" "default.target" ];
|
||||
script = ''
|
||||
sleep 2
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
|
|
@ -55,6 +93,7 @@ forEachUbuntuImage
|
|||
nodes = {
|
||||
node1 = { config, ... }: {
|
||||
modules = [
|
||||
(testModule "old")
|
||||
../../../examples/example.nix
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue