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

Collapse All | Expand All

(-)files/gitlab.in (-63 / +30 lines)
Lines 2-23 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
19
# PROVIDE: gitlab
8
# PROVIDE: gitlab
20
# REQUIRE: LOGIN
9
# REQUIRE: redis nginx LOGIN
21
# KEYWORD: shutdown
10
# KEYWORD: shutdown
22
#
11
#
23
# Add the following line to /etc/rc.conf to enable GitLab:
12
# Add the following line to /etc/rc.conf to enable GitLab:
Lines 32-52 Link Here
32
rcvar=gitlab_enable
21
rcvar=gitlab_enable
33
extra_commands=status
22
extra_commands=status
34
23
35
status_cmd="print_status"
24
: ${gitlab_user="git"}
36
start_cmd="start_gitlab"
25
: ${gitlab_railsenv="production"}
37
stop_cmd="stop_gitlab"
38
restart_cmd="restart_gitlab"
39
26
27
status_cmd="${name}_status"
28
start_cmd="${name}_start"
29
stop_cmd="${name}_stop"
30
#restart_cmd="${name}_restart"
31
32
extra_commands="status reload"
33
40
gitlab_enable=${gitlab_enable:-"NO"}
34
gitlab_enable=${gitlab_enable:-"NO"}
41
35
42
load_rc_config $name
36
load_rc_config $name
43
37
44
### Environment variables
38
### Environment variables
45
RAILS_ENV="production"
46
39
47
# Script variable names should be lower-case not to conflict with
40
# Script variable names should be lower-case not to conflict with
48
# internal /bin/sh variables such as PATH, EDITOR or SHELL.
41
# internal /bin/sh variables such as PATH, EDITOR or SHELL.
49
app_user="git"
42
app_user=${gitlab_user}
50
app_root="/usr/local/www/gitlab"
43
app_root="/usr/local/www/gitlab"
51
pid_path="$app_root/tmp/pids"
44
pid_path="$app_root/tmp/pids"
52
socket_path="$app_root/tmp/sockets"
45
socket_path="$app_root/tmp/sockets"
Lines 215-221 Link Here
215
}
208
}
216
209
217
## Starts Unicorn and Sidekiq if they're not running.
210
## Starts Unicorn and Sidekiq if they're not running.
218
start_gitlab() {
211
gitlab_start() {
219
  check_stale_pids
212
  check_stale_pids
220
213
221
  if [ "$web_status" != "0" ]; then
214
  if [ "$web_status" != "0" ]; then
Lines 238-244 Link Here
238
    # Remove old socket if it exists
231
    # Remove old socket if it exists
239
    rm -f "$socket_path"/gitlab.socket 2>/dev/null
232
    rm -f "$socket_path"/gitlab.socket 2>/dev/null
240
    # Start the web server
233
    # Start the web server
241
    RAILS_ENV=$RAILS_ENV bin/web start
234
    RAILS_ENV=$gitlab_railsenv bin/web start
242
  fi
235
  fi
243
236
244
  # If sidekiq is already running, don't start it again.
237
  # If sidekiq is already running, don't start it again.
Lines 245-251 Link Here
245
  if [ "$sidekiq_status" = "0" ]; then
238
  if [ "$sidekiq_status" = "0" ]; then
246
    echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting"
239
    echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting"
247
  else
240
  else
248
    RAILS_ENV=$RAILS_ENV bin/background_jobs start &
241
    RAILS_ENV=$gitlab_railsenv bin/background_jobs start &
249
  fi
242
  fi
250
243
251
  if [ "$gitlab_workhorse_status" = "0" ]; then
244
  if [ "$gitlab_workhorse_status" = "0" ]; then
Lines 265-271 Link Here
265
    if [ "$mail_room_status" = "0" ]; then
258
    if [ "$mail_room_status" = "0" ]; then
266
      echo "The MailRoom email processor is already running with pid $mpid, not restarting"
259
      echo "The MailRoom email processor is already running with pid $mpid, not restarting"
267
    else
260
    else
268
      RAILS_ENV=$RAILS_ENV bin/mail_room start &
261
      RAILS_ENV=$gitlab_railsenv bin/mail_room start &
269
    fi
262
    fi
270
  fi
263
  fi
271
264
Lines 272-291 Link Here
272
  # Wait for the pids to be planted
265
  # Wait for the pids to be planted
273
  wait_for_pids
266
  wait_for_pids
274
  # Finally check the status to tell wether or not GitLab is running
267
  # Finally check the status to tell wether or not GitLab is running
275
  print_status
268
  gitlab_status
276
}
269
}
277
270
278
## Asks Unicorn, Sidekiq and MailRoom if they would be so kind as to stop, if not kills them.
271
## Asks Unicorn, Sidekiq and MailRoom if they would be so kind as to stop, if not kills them.
279
stop_gitlab() {
272
gitlab_stop() {
280
  exit_if_not_running
273
  exit_if_not_running
281
274
282
  if [ "$web_status" = "0" ]; then
275
  if [ "$web_status" = "0" ]; then
283
    echo "Shutting down GitLab Unicorn"
276
    echo "Shutting down GitLab Unicorn"
284
    RAILS_ENV=$RAILS_ENV bin/web stop
277
    RAILS_ENV=$gitlab_railsenv bin/web stop
285
  fi
278
  fi
286
  if [ "$sidekiq_status" = "0" ]; then
279
  if [ "$sidekiq_status" = "0" ]; then
287
    echo "Shutting down GitLab Sidekiq"
280
    echo "Shutting down GitLab Sidekiq"
288
    RAILS_ENV=$RAILS_ENV bin/background_jobs stop
281
    RAILS_ENV=$gitlab_railsenv bin/background_jobs stop
289
  fi
282
  fi
290
  if [ "$gitlab_workhorse_status" = "0" ]; then
283
  if [ "$gitlab_workhorse_status" = "0" ]; then
291
    echo "Shutting down gitlab-workhorse"
284
    echo "Shutting down gitlab-workhorse"
Lines 293-299 Link Here
293
  fi
286
  fi
294
  if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
287
  if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
295
    echo "Shutting down GitLab MailRoom"
288
    echo "Shutting down GitLab MailRoom"
296
    RAILS_ENV=$RAILS_ENV bin/mail_room stop
289
    RAILS_ENV=$gitlab_railsenv bin/mail_room stop
297
  fi
290
  fi
298
291
299
  # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
292
  # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
Lines 316-326 Link Here
316
    rm "$mail_room_pid_path" 2>/dev/null
309
    rm "$mail_room_pid_path" 2>/dev/null
317
  fi
310
  fi
318
311
319
  print_status
312
  gitlab_status
320
}
313
}
321
314
322
## Prints the status of GitLab and its components.
315
## Prints the status of GitLab and its components.
323
print_status() {
316
gitlab_status() {
324
  check_status
317
  check_status
325
  if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_workhorse_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
318
  if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_workhorse_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
326
    echo "GitLab is not running."
319
    echo "GitLab is not running."
Lines 361-414 Link Here
361
    exit 1
354
    exit 1
362
  fi
355
  fi
363
  printf "Reloading GitLab Unicorn configuration... "
356
  printf "Reloading GitLab Unicorn configuration... "
364
  RAILS_ENV=$RAILS_ENV bin/web reload
357
  RAILS_ENV=$gitlab_railsenv bin/web reload
365
  echo "Done."
358
  echo "Done."
366
359
367
  echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
360
  echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
368
  RAILS_ENV=$RAILS_ENV bin/background_jobs restart
361
  RAILS_ENV=$gitlab_railsenv bin/background_jobs restart
369
362
370
  if [ "$mail_room_enabled" != true ]; then
363
  if [ "$mail_room_enabled" != true ]; then
371
    echo "Restarting GitLab MailRoom since it isn't capable of reloading its config..."
364
    echo "Restarting GitLab MailRoom since it isn't capable of reloading its config..."
372
    RAILS_ENV=$RAILS_ENV bin/mail_room restart
365
    RAILS_ENV=$gitlab_railsenv bin/mail_room restart
373
  fi
366
  fi
374
367
375
  wait_for_pids
368
  wait_for_pids
376
  print_status
369
  gitlab_status
377
}
370
}
378
371
379
## Restarts Sidekiq and Unicorn.
372
## Restarts Sidekiq and Unicorn.
380
restart_gitlab(){
373
gitlab_restart(){
381
  check_status
374
  check_status
382
  if [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_workhorse" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; then
375
  if [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_workhorse" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; then
383
    stop_gitlab
376
    gitlab_stop
384
  fi
377
  fi
385
  start_gitlab
378
  gitlab_start
386
}
379
}
387
380
388
381
run_rc_command "$1"
389
### Finally the input handling.
390
391
case "$1" in
392
  start)
393
        start_gitlab
394
        ;;
395
  stop)
396
        stop_gitlab
397
        ;;
398
  restart)
399
        restart_gitlab
400
        ;;
401
  reload|force-reload)
402
	reload_gitlab
403
        ;;
404
  status)
405
        print_status
406
        exit $gitlab_status
407
        ;;
408
  *)
409
        echo "Usage: service gitlab {start|stop|restart|reload|status}"
410
        exit 1
411
        ;;
412
esac
413
414
exit

Return to bug 208793