View | Details | Raw Unified | Return to bug 208793 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 4-10 Link Here
4
PORTNAME=	gitlab
4
PORTNAME=	gitlab
5
PORTVERSION=	8.11.11
5
PORTVERSION=	8.11.11
6
DISTVERSIONPREFIX=	v
6
DISTVERSIONPREFIX=	v
7
PORTREVISION=	6
7
PORTREVISION=	7
8
CATEGORIES=	www devel
8
CATEGORIES=	www devel
9
9
10
MAINTAINER=	tz@FreeBSD.org
10
MAINTAINER=	tz@FreeBSD.org
(-)files/gitlab.in (-90 / +38 lines)
Lines 2-18 Link Here
2
2
3
# $FreeBSD$
3
# $FreeBSD$
4
4
5
### BEGIN INIT INFO
6
# Provides:          gitlab
7
# Required-Start:    $local_fs $remote_fs $network $syslog redis-server
8
# Required-Stop:     $local_fs $remote_fs $network $syslog
9
# Default-Start:     2 3 4 5
10
# Default-Stop:      0 1 6
11
# Short-Description: GitLab git repository management
12
# Description:       GitLab git repository management
13
# chkconfig: - 85 14
14
### END INIT INFO
15
16
# Maintainer: Torsten Zuehlsdorff <ports@toco-domains.de>
5
# Maintainer: Torsten Zuehlsdorff <ports@toco-domains.de>
17
# Based on work of: @charlienewey, rovanion.luckey@gmail.com, @randx
6
# Based on work of: @charlienewey, rovanion.luckey@gmail.com, @randx
18
7
Lines 28-57 Link Here
28
17
29
. /etc/rc.subr
18
. /etc/rc.subr
30
19
31
name=gitlab
20
name="gitlab"
32
rcvar=gitlab_enable
21
rcvar="gitlab_enable"
33
extra_commands=status
34
35
status_cmd="print_status"
22
status_cmd="print_status"
36
start_cmd="start_gitlab"
23
start_cmd="start_gitlab"
37
stop_cmd="stop_gitlab"
24
stop_cmd="stop_gitlab"
38
restart_cmd="restart_gitlab"
25
restart_cmd="restart_gitlab"
26
extra_commands="reload status"
27
reload_cmd="reload_gitlab"
39
28
40
gitlab_enable=${gitlab_enable:-"NO"}
41
gitlab_authBackend=${gitlab_authBackend:-"http://127.0.0.1:8080"}
42
43
load_rc_config $name
29
load_rc_config $name
44
30
45
### Environment variables
31
: ${gitlab_enable:="NO"}
46
RAILS_ENV="production"
32
: ${gitlab_authBackend:"http://127.0.0.1:8080"}
33
: ${gitlab_user:="git"}
34
: ${gitlab_env:="production"}
47
35
36
run_env="env RAILS_ENV=$gitlab_env"
37
48
# Script variable names should be lower-case not to conflict with
38
# Script variable names should be lower-case not to conflict with
49
# internal /bin/sh variables such as PATH, EDITOR or SHELL.
39
# internal /bin/sh variables such as PATH, EDITOR or SHELL.
50
app_user="git"
51
app_root="/usr/local/www/gitlab"
40
app_root="/usr/local/www/gitlab"
52
pid_path="$app_root/tmp/pids"
41
pid_path="$app_root/tmp/pids"
53
socket_path="$app_root/tmp/sockets"
42
socket_path="$app_root/tmp/sockets"
54
rails_socket="$socket_path/gitlab.socket"
43
rails_socket="$socket_path/gitlab.socket"
44
workhorse_socket=$socket_path/gitlab-workhorse.socket
55
web_server_pid_path="$pid_path/unicorn.pid"
45
web_server_pid_path="$pid_path/unicorn.pid"
56
sidekiq_pid_path="$pid_path/sidekiq.pid"
46
sidekiq_pid_path="$pid_path/sidekiq.pid"
57
mail_room_enabled=false
47
mail_room_enabled=false
Lines 58-81 Link Here
58
mail_room_pid_path="$pid_path/mail_room.pid"
48
mail_room_pid_path="$pid_path/mail_room.pid"
59
gitlab_workhorse_dir=$(cd $app_root/../gitlab-workhorse && pwd)
49
gitlab_workhorse_dir=$(cd $app_root/../gitlab-workhorse && pwd)
60
gitlab_workhorse_pid_path="$pid_path/gitlab-workhorse.pid"
50
gitlab_workhorse_pid_path="$pid_path/gitlab-workhorse.pid"
61
gitlab_workhorse_options="-listenUmask 0 -listenNetwork unix -listenAddr $socket_path/gitlab-workhorse.socket -authBackend $gitlab_authBackend -authSocket $rails_socket -documentRoot $app_root/public"
51
gitlab_workhorse_options="-listenNetwork unix -listenAddr $workhorse_socket -authBackend $gitlab_authBackend -authSocket $rails_socket -documentRoot $app_root/public"
62
gitlab_workhorse_log="$app_root/log/gitlab-workhorse.log"
52
gitlab_workhorse_log="$app_root/log/gitlab-workhorse.log"
63
shell_path="/bin/bash"
64
53
65
# Read configuration variable file if it is present
66
test -f /etc/default/gitlab && . /etc/default/gitlab
67
68
# Switch to the app_user if it is not he/she who is running the script.
69
if [ "$USER" != "$app_user" ]; then
70
  eval su - "$app_user" -c $(echo \")$0 "$@"$(echo \"); exit;
71
fi
72
73
# Switch to the gitlab path, exit on failure.
74
if ! cd "$app_root" ; then
75
 echo "Failed to cd into $app_root, exiting!";  exit 1
76
fi
77
78
79
### Init Script functions
54
### Init Script functions
80
55
81
## Gets the pids from the files
56
## Gets the pids from the files
Lines 219-245 Link Here
219
start_gitlab() {
194
start_gitlab() {
220
  check_stale_pids
195
  check_stale_pids
221
196
222
  if [ "$web_status" != "0" ]; then
223
    echo "Starting GitLab Unicorn"
224
  fi
225
  if [ "$sidekiq_status" != "0" ]; then
226
    echo "Starting GitLab Sidekiq"
227
  fi
228
  if [ "$gitlab_workhorse_status" != "0" ]; then
229
    echo "Starting gitlab-workhorse"
230
  fi
231
  if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" != "0" ]; then
232
    echo "Starting GitLab MailRoom"
233
  fi
234
235
  # Then check if the service is running. If it is: don't start again.
197
  # Then check if the service is running. If it is: don't start again.
236
  if [ "$web_status" = "0" ]; then
198
  if [ "$web_status" = "0" ]; then
237
    echo "The Unicorn web server already running with pid $wpid, not restarting."
199
    echo "The Unicorn web server already running with pid $wpid, not restarting."
238
  else
200
  else
201
    echo "Starting GitLab Unicorn"
239
    # Remove old socket if it exists
202
    # Remove old socket if it exists
240
    rm -f "$socket_path"/gitlab.socket 2>/dev/null
203
    rm -f "$socket_path"/gitlab.socket 2>/dev/null
241
    # Start the web server
204
    # unicorn may break the current process on freebsd during 
242
    RAILS_ENV=$RAILS_ENV bin/web start
205
    # deamonizing (defunct exists until new master has prefilled 
206
    # caches) - therefore start itself is decoupled
207
    /usr/sbin/daemon -u ${gitlab_user} $run_env ${app_root}/bin/web start
208
    # 
243
  fi
209
  fi
244
210
245
  # If sidekiq is already running, don't start it again.
211
  # If sidekiq is already running, don't start it again.
Lines 246-252 Link Here
246
  if [ "$sidekiq_status" = "0" ]; then
212
  if [ "$sidekiq_status" = "0" ]; then
247
    echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting"
213
    echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting"
248
  else
214
  else
249
    RAILS_ENV=$RAILS_ENV bin/background_jobs start &
215
    echo "Starting GitLab Sidekiq"
216
    su - $gitlab_user -c "$run_env ${app_root}/bin/background_jobs start"
250
  fi
217
  fi
251
218
252
  if [ "$gitlab_workhorse_status" = "0" ]; then
219
  if [ "$gitlab_workhorse_status" = "0" ]; then
Lines 255-264 Link Here
255
    # No need to remove a socket, gitlab-workhorse does this itself.
222
    # No need to remove a socket, gitlab-workhorse does this itself.
256
    # Because gitlab-workhorse has multiple executables we need to fix
223
    # Because gitlab-workhorse has multiple executables we need to fix
257
    # the PATH.
224
    # the PATH.
258
    $app_root/bin/daemon_with_pidfile $gitlab_workhorse_pid_path  \
225
    echo "Starting gitlab-workhorse"
259
      /usr/bin/env PATH=$gitlab_workhorse_dir:$PATH \
226
    cd ${gitlab_workhorse_dir} &&
260
        gitlab-workhorse $gitlab_workhorse_options \
227
        /usr/sbin/daemon -p $gitlab_workhorse_pid_path \
261
      >> $gitlab_workhorse_log 2>&1 &
228
          -u $gitlab_user -t gitlab-workhorse $run_env \
229
            $gitlab_workhorse_dir/gitlab-workhorse $gitlab_workhorse_options \
230
            >> $gitlab_workhorse_log 2>&1
262
  fi
231
  fi
263
232
264
  if [ "$mail_room_enabled" = true ]; then
233
  if [ "$mail_room_enabled" = true ]; then
Lines 266-272 Link Here
266
    if [ "$mail_room_status" = "0" ]; then
235
    if [ "$mail_room_status" = "0" ]; then
267
      echo "The MailRoom email processor is already running with pid $mpid, not restarting"
236
      echo "The MailRoom email processor is already running with pid $mpid, not restarting"
268
    else
237
    else
269
      RAILS_ENV=$RAILS_ENV bin/mail_room start &
238
        echo "Starting GitLab MailRoom"
239
        su - $gitlab_user -c "$run_env ${app_root}/bin/mail_room start"
270
    fi
240
    fi
271
  fi
241
  fi
272
242
Lines 282-300 Link Here
282
252
283
  if [ "$web_status" = "0" ]; then
253
  if [ "$web_status" = "0" ]; then
284
    echo "Shutting down GitLab Unicorn"
254
    echo "Shutting down GitLab Unicorn"
285
    RAILS_ENV=$RAILS_ENV bin/web stop
255
    su - $gitlab_user -c "$run_env ${app_root}/bin/web stop"
256
    [ -S ${rails_socket} ] && rm -f ${rails_socket}
286
  fi
257
  fi
287
  if [ "$sidekiq_status" = "0" ]; then
258
  if [ "$sidekiq_status" = "0" ]; then
288
    echo "Shutting down GitLab Sidekiq"
259
    echo "Shutting down GitLab Sidekiq"
289
    RAILS_ENV=$RAILS_ENV bin/background_jobs stop
260
    su - $gitlab_user -c "$run_env ${app_root}/bin/background_jobs stop"
290
  fi
261
  fi
291
  if [ "$gitlab_workhorse_status" = "0" ]; then
262
  if [ "$gitlab_workhorse_status" = "0" ]; then
292
    echo "Shutting down gitlab-workhorse"
263
    echo "Shutting down gitlab-workhorse"
293
    kill -- $(cat $gitlab_workhorse_pid_path)
264
    kill -- $(cat $gitlab_workhorse_pid_path)
265
    [ -S ${workhorse_socket} ] && rm -f ${workhorse_socket}
294
  fi
266
  fi
295
  if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
267
  if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
296
    echo "Shutting down GitLab MailRoom"
268
    echo "Shutting down GitLab MailRoom"
297
    RAILS_ENV=$RAILS_ENV bin/mail_room stop
269
    su - $gitlab_user -c "$run_env ${app_root}/bin/mail_room stop"
298
  fi
270
  fi
299
271
300
  # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
272
  # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
Lines 362-376 Link Here
362
    exit 1
334
    exit 1
363
  fi
335
  fi
364
  printf "Reloading GitLab Unicorn configuration... "
336
  printf "Reloading GitLab Unicorn configuration... "
365
  RAILS_ENV=$RAILS_ENV bin/web reload
337
  su - $gitlab_user -c "$run_env ${app_root}/bin/web reload"
366
  echo "Done."
338
  echo "Done."
367
339
368
  echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
340
  echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
369
  RAILS_ENV=$RAILS_ENV bin/background_jobs restart
341
  su - $gitlab_user -c "$run_env ${app_root}/bin/background_jobs restart"
370
342
371
  if [ "$mail_room_enabled" != true ]; then
343
  if [ "$mail_room_enabled" = true ]; then
372
    echo "Restarting GitLab MailRoom since it isn't capable of reloading its config..."
344
    echo "Restarting GitLab MailRoom since it isn't capable of reloading its config..."
373
    RAILS_ENV=$RAILS_ENV bin/mail_room restart
345
    su - $gitlab_user -c "$run_env ${app_root}/bin/mail_room restart"
374
  fi
346
  fi
375
347
376
  wait_for_pids
348
  wait_for_pids
Lines 387-415 Link Here
387
}
359
}
388
360
389
361
390
### Finally the input handling.
391
362
392
case "$1" in
363
run_rc_command "$1"
393
  start)
394
        start_gitlab
395
        ;;
396
  stop)
397
        stop_gitlab
398
        ;;
399
  restart)
400
        restart_gitlab
401
        ;;
402
  reload|force-reload)
403
	reload_gitlab
404
        ;;
405
  status)
406
        print_status
407
        exit $gitlab_status
408
        ;;
409
  *)
410
        echo "Usage: service gitlab {start|stop|restart|reload|status}"
411
        exit 1
412
        ;;
413
esac
414
415
exit

Return to bug 208793