nixos/mastodon: fix start services

authored by Izorkin and committed by Kerstin 2bb8cc27 ad0739b9

+25 -15
+25 -15
nixos/modules/services/web-apps/mastodon.nix
··· 475 475 } // cfgService; 476 476 477 477 after = [ "network.target" ]; 478 - wantedBy = [ "multi-user.target" ]; 479 478 }; 480 479 481 480 systemd.services.mastodon-init-db = lib.mkIf cfg.automaticMigrations { ··· 500 499 # System Call Filtering 501 500 SystemCallFilter = [ ("~" + lib.concatStringsSep " " (systemCallsList ++ [ "@resources" ])) "@chown" "pipe" "pipe2" ]; 502 501 } // cfgService; 503 - after = [ "mastodon-init-dirs.service" "network.target" ] ++ (if databaseActuallyCreateLocally then [ "postgresql.service" ] else []); 504 - wantedBy = [ "multi-user.target" ]; 502 + after = [ "network.target" "mastodon-init-dirs.service" ] 503 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service"; 504 + requires = [ "mastodon-init-dirs.service" ] 505 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service"; 505 506 }; 506 507 507 508 systemd.services.mastodon-streaming = { 508 - after = [ "network.target" ] 509 - ++ (if databaseActuallyCreateLocally then [ "postgresql.service" ] else []) 510 - ++ (if cfg.automaticMigrations then [ "mastodon-init-db.service" ] else [ "mastodon-init-dirs.service" ]); 511 - description = "Mastodon streaming"; 509 + after = [ "network.target" "mastodon-init-dirs.service" ] 510 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 511 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 512 + requires = [ "mastodon-init-dirs.service" ] 513 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 514 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 512 515 wantedBy = [ "multi-user.target" ]; 516 + description = "Mastodon streaming"; 513 517 environment = env // (if cfg.enableUnixSocket 514 518 then { SOCKET = "/run/mastodon-streaming/streaming.socket"; } 515 519 else { PORT = toString(cfg.streamingPort); } ··· 529 533 }; 530 534 531 535 systemd.services.mastodon-web = { 532 - after = [ "network.target" ] 533 - ++ (if databaseActuallyCreateLocally then [ "postgresql.service" ] else []) 534 - ++ (if cfg.automaticMigrations then [ "mastodon-init-db.service" ] else [ "mastodon-init-dirs.service" ]); 535 - description = "Mastodon web"; 536 + after = [ "network.target" "mastodon-init-dirs.service" ] 537 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 538 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 539 + requires = [ "mastodon-init-dirs.service" ] 540 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 541 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 536 542 wantedBy = [ "multi-user.target" ]; 543 + description = "Mastodon web"; 537 544 environment = env // (if cfg.enableUnixSocket 538 545 then { SOCKET = "/run/mastodon-web/web.socket"; } 539 546 else { PORT = toString(cfg.webPort); } ··· 554 561 }; 555 562 556 563 systemd.services.mastodon-sidekiq = { 557 - after = [ "network.target" ] 558 - ++ (if databaseActuallyCreateLocally then [ "postgresql.service" ] else []) 559 - ++ (if cfg.automaticMigrations then [ "mastodon-init-db.service" ] else [ "mastodon-init-dirs.service" ]); 564 + after = [ "network.target" "mastodon-init-dirs.service" ] 565 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 566 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 567 + requires = [ "mastodon-init-dirs.service" ] 568 + ++ lib.optional databaseActuallyCreateLocally "postgresql.service" 569 + ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; 570 + wantedBy = [ "multi-user.target" ]; 560 571 description = "Mastodon sidekiq"; 561 - wantedBy = [ "multi-user.target" ]; 562 572 environment = env // { 563 573 PORT = toString(cfg.sidekiqPort); 564 574 DB_POOL = toString cfg.sidekiqThreads;