mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 13:55:39 +00:00
Env var to disable db migrations, nix: drop pre-start service
This commit is contained in:
@@ -235,32 +235,8 @@ in
|
||||
# }
|
||||
];
|
||||
|
||||
systemd.services.spacebar-apply-migrations = makeServerTsService {
|
||||
description = "Spacebar Server - Apply DB migrations";
|
||||
# after = lib.optional config.services.postgresql.enable "postgresql.service";
|
||||
# requires = lib.optional config.services.postgresql.enable "postgresql.service";
|
||||
environment = builtins.mapAttrs (_: val: builtins.toString val) (
|
||||
cfg.extraEnvironment
|
||||
// {
|
||||
# things we force...
|
||||
CONFIG_PATH = configFile;
|
||||
CONFIG_READONLY = 1;
|
||||
}
|
||||
);
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/apply-migrations";
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
TimeoutStartSec = 45;
|
||||
RestartSec = 1;
|
||||
StartLimitBurst = 10;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.spacebar-api = makeServerTsService {
|
||||
description = "Spacebar Server - API";
|
||||
after = [ "spacebar-apply-migrations.service" ];
|
||||
requires = [ "spacebar-apply-migrations.service" ];
|
||||
environment = builtins.mapAttrs (_: val: builtins.toString val) (
|
||||
{
|
||||
# things we set by default...
|
||||
@@ -283,8 +259,6 @@ in
|
||||
|
||||
systemd.services.spacebar-gateway = makeServerTsService {
|
||||
description = "Spacebar Server - Gateway";
|
||||
after = [ "spacebar-apply-migrations.service" ];
|
||||
requires = [ "spacebar-apply-migrations.service" ];
|
||||
environment = builtins.mapAttrs (_: val: builtins.toString val) (
|
||||
{
|
||||
# things we set by default...
|
||||
@@ -298,6 +272,7 @@ in
|
||||
CONFIG_READONLY = 1;
|
||||
PORT = toString cfg.gatewayEndpoint.localPort;
|
||||
STORAGE_LOCATION = cfg.cdnPath;
|
||||
APPLY_DB_MIGRATIONS = false;
|
||||
}
|
||||
);
|
||||
serviceConfig = {
|
||||
@@ -307,8 +282,6 @@ in
|
||||
|
||||
systemd.services.spacebar-cdn = lib.mkIf (!cfg.enableCdnCs) (makeServerTsService {
|
||||
description = "Spacebar Server - CDN";
|
||||
after = [ "spacebar-apply-migrations.service" ];
|
||||
requires = [ "spacebar-apply-migrations.service" ];
|
||||
environment = builtins.mapAttrs (_: val: builtins.toString val) (
|
||||
{
|
||||
# things we set by default...
|
||||
@@ -322,6 +295,7 @@ in
|
||||
CONFIG_READONLY = 1;
|
||||
PORT = toString cfg.cdnEndpoint.localPort;
|
||||
STORAGE_LOCATION = cfg.cdnPath;
|
||||
APPLY_DB_MIGRATIONS = false;
|
||||
}
|
||||
);
|
||||
serviceConfig = {
|
||||
|
||||
@@ -132,8 +132,10 @@ export async function initDatabase(): Promise<DataSource> {
|
||||
await qr.release();
|
||||
}
|
||||
|
||||
console.log("[Database] Applying missing migrations, if any.");
|
||||
await dbConnection.runMigrations();
|
||||
if (process.env.APPLY_DB_MIGRATIONS !== "false") {
|
||||
console.log("[Database] Applying missing migrations, if any.");
|
||||
await dbConnection.runMigrations();
|
||||
}
|
||||
|
||||
console.log(`[Database] ${green("Connected")}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user