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。

轉載自:多客博圖


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM