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.
This commit is contained in:
Peter Jones 2019-03-04 13:20:28 -07:00
parent c45f05c96c
commit 41475bbde5
No known key found for this signature in database
GPG key ID: 9DAFAA8D01941E49
2 changed files with 11 additions and 2 deletions

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 = {

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: