Browse Source

Add the ability for Rails apps to depend on configured services

The new `afterServices' setting allows a Rails app to depend on
arbitrary systemd services.
pjones/monitoring
Peter J. Jones 8 months ago
parent
commit
41475bbde5
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
2 changed files with 11 additions and 2 deletions
  1. 7
    0
      modules/services/web/rails/options.nix
  2. 4
    2
      modules/services/web/rails/systemd.nix

+ 7
- 0
modules/services/web/rails/options.nix View File

@@ -186,6 +186,13 @@ let
should really use the Rails secrets system.
'';
};

afterServices = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "foo-key.service" ];
description = "Additional services to start before Rails.";
};
};

config = {

+ 4
- 2
modules/services/web/rails/systemd.nix View File

@@ -39,7 +39,8 @@ let

wants =
plib.keyService app.database.passwordFile ++
plib.keyService app.sourcedFile;
plib.keyService app.sourcedFile ++
app.afterServices;

after =
[ "network.target" ] ++
@@ -47,7 +48,8 @@ let
optional funcs.localpg "pg-accounts.service" ++
optional (!service.isMain) "rails-${app.name}-main" ++
plib.keyService app.database.passwordFile ++
plib.keyService app.sourcedFile;
plib.keyService app.sourcedFile ++
app.afterServices;

preStart = optionalString service.isMain ''
# Prepare the config directory:

Loading…
Cancel
Save