Gitlab启动所有服务的方式

gitlab开机启动是一个systemd的脚本(multi-user.target.wants可能是同级目录下其他文件夹):

/et/systemd/system/multi-user.target.wants/gitlab-runsvdir.service

内容很简单,就是执行一条命令:

[Unit]
Description=GitLab Runit supervision process
After=basic.target

[Service]
ExecStart=/opt/gitlab/embedded/bin/runsvdir-start
Restart=always

[Install]
WantedBy=basic.target

而,/opt/gitlab/embedded/bin/runsvdir-start 这个脚本是干什么的呢?看看内容,最主要的一句就是:

exec env - PATH=$PATH \

runsvdir -P /opt/gitlab/service 'log: ............

runsvdir就是执行一个文件夹下面的所有的子文件夹的服务,而/opt/gitlab/service这个下面的服务有:

pi@raspberrypi:/opt/gitlab/sv $ ll
total 28
drwxr-xr-x 4 root root 4096 Nov 25 21:06 gitlab-workhorse
drwxr-xr-x 5 root root 4096 Nov 25 21:06 logrotate
drwxr-xr-x 4 root root 4096 Nov 25 21:06 nginx
drwxr-xr-x 5 root root 4096 Nov 25 21:06 postgresql
drwxr-xr-x 4 root root 4096 Nov 25 21:06 redis
drwxr-xr-x 4 root root 4096 Nov 25 21:06 sidekiq
drwxr-xr-x 5 root root 4096 Nov 25 21:06 unicorn

这样有一个好处,就是,自己启动自己的定制服务,而不需要系统层面也安装这些,比如nginx和unicorn。

再来看看系统启动的这些服务:

pi@raspberrypi:~ $ ps aux | grep runsv
root    542 0.0 0.0  1836  924 ?    Ss  22:21  0:00 runsvdir -P /opt/gitlab/service log:
root    702 0.0 0.0  1692  356 ?    Ss  22:21  0:00 runsv sidekiq
root    703 0.0 0.0  1692  364 ?    Ss  22:21  0:00 runsv unicorn
root    704 0.0 0.0  1692  340 ?    Ss  22:21  0:00 runsv logrotate
root    705 0.0 0.0  1692  356 ?    Ss  22:21  0:00 runsv nginx
root    706 0.0 0.0  1692  320 ?    Ss  22:21  0:00 runsv redis
root    707 0.0 0.0  1692  324 ?    Ss  22:21  0:00 runsv gitlab-workhorse
root    708 0.0 0.0  1692  308 ?    Ss  22:21  0:00 runsv postgresql
pi    3334 0.0 0.1  4280 1912 pts/0  S+  22:50  0:00 grep --color=auto runsv

可见,runsvdir把指定的子目录都运行了,而且要求生成log。

转载自:多客博图

posted on 2022-03-03 10:26  德邦总管  阅读(1035)  评论(0编辑  收藏  举报

导航