Changed the startup script to be able to work together with cbsd.

Parts of it where written by Oleg Ginzburg I only had to do some small modifications, thanks for this support.

Submitted by:	Oleg Ginzburg
This commit is contained in:
Matthias Fechner 2021-02-16 22:22:27 +00:00
parent 00773c6a97
commit c1b4dec5af
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=565466
2 changed files with 89 additions and 85 deletions

View file

@ -3,7 +3,7 @@
PORTNAME?= gitlab-ce PORTNAME?= gitlab-ce
PORTVERSION?= 13.8.4 PORTVERSION?= 13.8.4
PORTREVISION?= 0 PORTREVISION?= 1
CATEGORIES= www devel CATEGORIES= www devel
MAINTAINER= mfechner@FreeBSD.org MAINTAINER= mfechner@FreeBSD.org

View file

@ -36,6 +36,10 @@ status_cmd="print_status"
start_cmd="start_gitlab" start_cmd="start_gitlab"
stop_cmd="stop_gitlab" stop_cmd="stop_gitlab"
restart_cmd="restart_gitlab" restart_cmd="restart_gitlab"
service_args="$@"
restart_precmd=${name}_init
start_precmd=${name}_init
stop_precmd=${name}_init
: ${gitlab_enable:="NO"} : ${gitlab_enable:="NO"}
: ${gitlab_authBackend:="http://127.0.0.1:8080"} : ${gitlab_authBackend:="http://127.0.0.1:8080"}
@ -97,6 +101,60 @@ gitaly_dir="%%PREFIX%%/share/gitaly"
gitaly_pid_path="$pid_path/gitaly.pid" gitaly_pid_path="$pid_path/gitaly.pid"
gitaly_log="$app_root/log/gitaly.log" gitaly_log="$app_root/log/gitaly.log"
if [ -z "$SIDEKIQ_WORKERS" ]; then
sidekiq_pid_path="$pid_path/sidekiq.pid"
else
sidekiq_pid_path="$pid_path/sidekiq-cluster.pid"
fi
### Init Script functions
## Gets the pids from the files
check_pids(){
if ! mkdir -p "$pid_path"; then
echo "Could not create the path $pid_path needed to store the pids."
exit 1
fi
# If there exists a file which should hold the value of the web server pid: read it.
if [ -f "$web_server_pid_path" ]; then
wpid=$(cat "$web_server_pid_path")
else
wpid=0
fi
if [ -f "$sidekiq_pid_path" ]; then
spid=$(cat "$sidekiq_pid_path")
else
spid=0
fi
if [ -f "$gitlab_workhorse_pid_path" ]; then
hpid=$(cat "$gitlab_workhorse_pid_path")
else
hpid=0
fi
if [ "$mail_room_enabled" = true ]; then
if [ -f "$mail_room_pid_path" ]; then
mpid=$(cat "$mail_room_pid_path")
else
mpid=0
fi
fi
if [ "$gitlab_pages_enabled" = true ]; then
if [ -f "$gitlab_pages_pid_path" ]; then
gppid=$(cat "$gitlab_pages_pid_path")
else
gppid=0
fi
fi
if [ "$gitaly_enabled" = true ]; then
if [ -f "$gitaly_pid_path" ]; then
gapid=$(cat "$gitaly_pid_path")
else
gapid=0
fi
fi
}
gitlab_init(){
# Read configuration variable file if it is present # Read configuration variable file if it is present
test -f /etc/default/gitlab && . /etc/default/gitlab test -f /etc/default/gitlab && . /etc/default/gitlab
@ -155,7 +213,7 @@ if [ "$USER" != "$app_user" ]; then
exit 1 exit 1
fi fi
eval su - "$app_user" -c $(echo \")%%LOCALBASE%%/etc/rc.d/gitlab "$@"$(echo \"); exit; eval su - "$app_user" -c $(echo \")%%LOCALBASE%%/etc/rc.d/gitlab "${service_args}"$(echo \"); exit;
fi fi
# Switch to the gitlab path, exit on failure. # Switch to the gitlab path, exit on failure.
@ -163,57 +221,9 @@ if ! cd "$app_root" ; then
echo "Failed to cd into $app_root, exiting!"; exit 1 echo "Failed to cd into $app_root, exiting!"; exit 1
fi fi
if [ -z "$SIDEKIQ_WORKERS" ]; then # We use the pids in so many parts of the script it makes sense to always check them.
sidekiq_pid_path="$pid_path/sidekiq.pid" # Only after start() is run should the pids change. Sidekiq sets its own pid.
else check_pids
sidekiq_pid_path="$pid_path/sidekiq-cluster.pid"
fi
### Init Script functions
## Gets the pids from the files
check_pids(){
if ! mkdir -p "$pid_path"; then
echo "Could not create the path $pid_path needed to store the pids."
exit 1
fi
# If there exists a file which should hold the value of the web server pid: read it.
if [ -f "$web_server_pid_path" ]; then
wpid=$(cat "$web_server_pid_path")
else
wpid=0
fi
if [ -f "$sidekiq_pid_path" ]; then
spid=$(cat "$sidekiq_pid_path")
else
spid=0
fi
if [ -f "$gitlab_workhorse_pid_path" ]; then
hpid=$(cat "$gitlab_workhorse_pid_path")
else
hpid=0
fi
if [ "$mail_room_enabled" = true ]; then
if [ -f "$mail_room_pid_path" ]; then
mpid=$(cat "$mail_room_pid_path")
else
mpid=0
fi
fi
if [ "$gitlab_pages_enabled" = true ]; then
if [ -f "$gitlab_pages_pid_path" ]; then
gppid=$(cat "$gitlab_pages_pid_path")
else
gppid=0
fi
fi
if [ "$gitaly_enabled" = true ]; then
if [ -f "$gitaly_pid_path" ]; then
gapid=$(cat "$gitaly_pid_path")
else
gapid=0
fi
fi
} }
## Called when we have started the two processes and are waiting for their pid files. ## Called when we have started the two processes and are waiting for their pid files.
@ -234,11 +244,6 @@ wait_for_pids(){
echo "Started in ${i}s." echo "Started in ${i}s."
} }
# We use the pids in so many parts of the script it makes sense to always check them.
# Only after start() is run should the pids change. Sidekiq sets its own pid.
check_pids
## Checks whether the different parts of the service are already running or not. ## Checks whether the different parts of the service are already running or not.
check_status(){ check_status(){
check_pids check_pids
@ -573,7 +578,6 @@ restart_gitlab(){
start_gitlab start_gitlab
} }
run_rc_command "$1" run_rc_command "$1"
exit exit