nixos/gitlab: Add gitlab.target

To make it easier to start and stop all GitLab services, introduce
`gitlab.target` which wants all services (meaning they will start with
it) and which all services are part of (meaning they will stop with
it).
This commit is contained in:
talyz 2021-02-25 11:33:06 +01:00
parent f38c601b54
commit ca725e7fcd
No known key found for this signature in database
GPG Key ID: 2DED2151F4671A2B

View File

@ -641,6 +641,11 @@ in {
environment.systemPackages = [ pkgs.git gitlab-rake gitlab-rails cfg.packages.gitlab-shell ]; environment.systemPackages = [ pkgs.git gitlab-rake gitlab-rails cfg.packages.gitlab-shell ];
systemd.targets.gitlab = {
description = "Common target for all GitLab services.";
wantedBy = [ "multi-user.target" ];
};
# Redis is required for the sidekiq queue runner. # Redis is required for the sidekiq queue runner.
services.redis.enable = mkDefault true; services.redis.enable = mkDefault true;
@ -656,7 +661,8 @@ in {
systemd.services.gitlab-postgresql = let pgsql = config.services.postgresql; in mkIf databaseActuallyCreateLocally { systemd.services.gitlab-postgresql = let pgsql = config.services.postgresql; in mkIf databaseActuallyCreateLocally {
after = [ "postgresql.service" ]; after = [ "postgresql.service" ];
bindsTo = [ "postgresql.service" ]; bindsTo = [ "postgresql.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = [ path = [
pgsql.package pgsql.package
pkgs.util-linux pkgs.util-linux
@ -737,7 +743,8 @@ in {
systemd.services.gitlab-config = { systemd.services.gitlab-config = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [ path = with pkgs; [
jq jq
openssl openssl
@ -845,7 +852,8 @@ in {
"gitlab-config.service" "gitlab-config.service"
] ++ optional (cfg.databaseHost == "") "postgresql.service" ] ++ optional (cfg.databaseHost == "") "postgresql.service"
++ optional databaseActuallyCreateLocally "gitlab-postgresql.service"; ++ optional databaseActuallyCreateLocally "gitlab-postgresql.service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
User = cfg.user; User = cfg.user;
@ -879,7 +887,8 @@ in {
"gitlab-config.service" "gitlab-config.service"
"gitlab-db-config.service" "gitlab-db-config.service"
] ++ optional (cfg.databaseHost == "") "postgresql.service"; ] ++ optional (cfg.databaseHost == "") "postgresql.service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
environment = gitlabEnv; environment = gitlabEnv;
path = with pkgs; [ path = with pkgs; [
postgresqlPackage postgresqlPackage
@ -907,7 +916,8 @@ in {
systemd.services.gitaly = { systemd.services.gitaly = {
after = [ "network.target" "gitlab-config.service" ]; after = [ "network.target" "gitlab-config.service" ];
bindsTo = [ "gitlab-config.service" ]; bindsTo = [ "gitlab-config.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [ path = with pkgs; [
openssh openssh
procps # See https://gitlab.com/gitlab-org/gitaly/issues/1562 procps # See https://gitlab.com/gitlab-org/gitaly/issues/1562
@ -932,7 +942,8 @@ in {
description = "GitLab static pages daemon"; description = "GitLab static pages daemon";
after = [ "network.target" "gitlab-config.service" ]; after = [ "network.target" "gitlab-config.service" ];
bindsTo = [ "gitlab-config.service" ]; bindsTo = [ "gitlab-config.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = [ pkgs.unzip ]; path = [ pkgs.unzip ];
@ -951,7 +962,8 @@ in {
systemd.services.gitlab-workhorse = { systemd.services.gitlab-workhorse = {
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [ path = with pkgs; [
exiftool exiftool
git git
@ -982,7 +994,8 @@ in {
description = "GitLab incoming mail daemon"; description = "GitLab incoming mail daemon";
after = [ "network.target" "redis.service" "gitlab-config.service" ]; after = [ "network.target" "redis.service" "gitlab-config.service" ];
bindsTo = [ "gitlab-config.service" ]; bindsTo = [ "gitlab-config.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
environment = gitlabEnv; environment = gitlabEnv;
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
@ -1009,7 +1022,8 @@ in {
"gitlab-config.service" "gitlab-config.service"
"gitlab-db-config.service" "gitlab-db-config.service"
] ++ optional (cfg.databaseHost == "") "postgresql.service"; ] ++ optional (cfg.databaseHost == "") "postgresql.service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
environment = gitlabEnv; environment = gitlabEnv;
path = with pkgs; [ path = with pkgs; [
postgresqlPackage postgresqlPackage