nixos/{object,toot}: Ensure postgres is accessible on service start
This commit is contained in:
parent
eceb1ba892
commit
c546331129
@ -126,6 +126,15 @@ rec {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemdAwaitPostgres = pkg: host: {
|
||||||
|
after = [ "systemd-networkd-wait-online.service" ];
|
||||||
|
preStart = ''
|
||||||
|
until ${pkg}/bin/pg_isready -h ${host}; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
deploy-rs =
|
deploy-rs =
|
||||||
with types;
|
with types;
|
||||||
let
|
let
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
let
|
let
|
||||||
inherit (lib) mkMerge mkIf;
|
inherit (lib) mkMerge mkIf;
|
||||||
inherit (config.my.user.homeConfig.lib.file) mkOutOfStoreSymlink;
|
inherit (config.my.user.homeConfig.lib.file) mkOutOfStoreSymlink;
|
||||||
inherit (lib.my) networkdAssignment;
|
inherit (lib.my) networkdAssignment systemdAwaitPostgres;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
@ -63,6 +63,7 @@
|
|||||||
MINIO_BROWSER_REDIRECT_URL = "https://minio.nul.ie";
|
MINIO_BROWSER_REDIRECT_URL = "https://minio.nul.ie";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
sharry = systemdAwaitPostgres pkgs.postgresql "colony-psql";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,7 +83,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
sharry = {
|
sharry = {
|
||||||
# TODO: wait for postgres connection to succeed
|
|
||||||
enable = true;
|
enable = true;
|
||||||
configOverridesFile = config.age.secrets."object/sharry.conf".path;
|
configOverridesFile = config.age.secrets."object/sharry.conf".path;
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
configuration = { lib, pkgs, config, assignments, allAssignments, ... }:
|
configuration = { lib, pkgs, config, assignments, allAssignments, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkMerge mkIf genAttrs mkBefore;
|
inherit (lib) mkMerge mkIf genAttrs;
|
||||||
inherit (lib.my) networkdAssignment;
|
inherit (lib.my) networkdAssignment systemdAwaitPostgres;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
@ -61,9 +61,7 @@
|
|||||||
mastodon-init-dirs.script = ''
|
mastodon-init-dirs.script = ''
|
||||||
echo "AWS_SECRET_ACCESS_KEY=\""$(< ${config.age.secrets."toot/s3-secret-key.txt".path})"\"" >> /var/lib/mastodon/.secrets_env
|
echo "AWS_SECRET_ACCESS_KEY=\""$(< ${config.age.secrets."toot/s3-secret-key.txt".path})"\"" >> /var/lib/mastodon/.secrets_env
|
||||||
'';
|
'';
|
||||||
mastodon-init-db = {
|
mastodon-init-db = systemdAwaitPostgres pkgs.postgresql "colony-psql";
|
||||||
after = [ "systemd-networkd-wait-online.service" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Can't use the extraConfig because these services expect a different format for the both family bind address...
|
# Can't use the extraConfig because these services expect a different format for the both family bind address...
|
||||||
mastodon-streaming.environment.BIND = "::";
|
mastodon-streaming.environment.BIND = "::";
|
||||||
|
Loading…
Reference in New Issue
Block a user