From 686162011c524a0eb077968d4f925d7244366a60 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Fri, 10 Oct 2014 23:46:53 +0530 Subject: [PATCH 1/4] init: execute `gitlab:satellites:create` rake task before starting gitlab --- assets/init | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/init b/assets/init index fbf6c72b..ec7d9ec9 100755 --- a/assets/init +++ b/assets/init @@ -668,11 +668,14 @@ appStart () { rm -rf tmp/pids/unicorn.pid rm -rf tmp/pids/sidekiq.pid + # create satellite directories + echo "Creating satellites..." + sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production >/dev/null + # start the gitlab application sudo -u git -H /etc/init.d/gitlab start - # create satellite directories - sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production + # perform status check sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production # setup cron job for automatic backups From bc05a0e792c0b670c35a1c4a5cc6a51065a39738 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Sat, 11 Oct 2014 00:01:36 +0530 Subject: [PATCH 2/4] init: start unicorn and sidekiq using supervisord --- assets/init | 15 ++++++++++++--- assets/setup/install | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/assets/init b/assets/init index ec7d9ec9..1a224417 100755 --- a/assets/init +++ b/assets/init @@ -668,12 +668,18 @@ appStart () { rm -rf tmp/pids/unicorn.pid rm -rf tmp/pids/sidekiq.pid + # remove state unicorn socket if it exists + rm -rf tmp/sockets/gitlab.socket + # create satellite directories echo "Creating satellites..." sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production >/dev/null - # start the gitlab application - sudo -u git -H /etc/init.d/gitlab start + echo "Starting unicorn..." + supervisorctl start unicorn >/dev/null + + echo "Starting sidekiq..." + supervisorctl start sidekiq >/dev/null # perform status check sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production @@ -699,7 +705,10 @@ EOF appStop() { echo "" - /etc/init.d/gitlab stop + echo "Stopping unicorn..." + supervisorctl stop unicorn >/dev/null + echo "Stopping sidekiq..." + supervisorctl stop sidekiq >/dev/nul echo "Stopping crond..." supervisorctl stop cron >/dev/null echo "Stopping sshd..." diff --git a/assets/setup/install b/assets/setup/install index 00947bac..2e9e66c1 100755 --- a/assets/setup/install +++ b/assets/setup/install @@ -118,6 +118,44 @@ cat > /etc/logrotate.d/supervisord < /etc/supervisor/conf.d/unicorn.conf < /etc/supervisor/conf.d/sidekiq.conf < /etc/supervisor/conf.d/sshd.conf < Date: Sat, 11 Oct 2014 00:26:38 +0530 Subject: [PATCH 3/4] init: do not execute `gitlab:check` rake task In the forthcoming commit all daemons will be auto started using supervisord and the execution of the init script will end at the launch of supervisord. This does not allow room for the `gitlab:check` task to be executed in such a way that its output. User's will need to login to the container and manually start the `gitlab:check` task if the wish to check the status. --- assets/init | 3 --- 1 file changed, 3 deletions(-) diff --git a/assets/init b/assets/init index 1a224417..05aaac2e 100755 --- a/assets/init +++ b/assets/init @@ -681,9 +681,6 @@ appStart () { echo "Starting sidekiq..." supervisorctl start sidekiq >/dev/null - # perform status check - sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production - # setup cron job for automatic backups case "${GITLAB_BACKUPS}" in daily) From 6094a7d449bdbb18a7617913cd2a9199d4c42b59 Mon Sep 17 00:00:00 2001 From: Sameer Naik Date: Sat, 11 Oct 2014 00:31:31 +0530 Subject: [PATCH 4/4] init: autostart all daemons when supervisord is started --- assets/init | 42 +++--------------------------------------- assets/setup/install | 10 +++++----- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/assets/init b/assets/init index 05aaac2e..1f1417aa 100755 --- a/assets/init +++ b/assets/init @@ -1,8 +1,6 @@ #!/bin/bash set -e -trap appStop SIGINT SIGTERM - GITLAB_INSTALL_DIR="/home/git/gitlab" GITLAB_DATA_DIR="/home/git/data" GITLAB_BACKUP_DIR="${GITLAB_BACKUP_DIR:-$GITLAB_DATA_DIR/backups}" @@ -273,9 +271,6 @@ fi # configure sshd to pick up the host keys from ${GITLAB_DATA_DIR}/ssh/ sed -i 's,HostKey /etc/ssh/,HostKey '"${GITLAB_DATA_DIR}"'/ssh/,g' -i /etc/ssh/sshd_config -# start supervisord -/usr/bin/supervisord -c /etc/supervisor/supervisord.conf - cd ${GITLAB_INSTALL_DIR} # copy configuration templates @@ -592,15 +587,6 @@ chmod 600 ${GITLAB_DATA_DIR}/.ssh/authorized_keys chown -R git:git ${GITLAB_DATA_DIR}/.ssh appStart () { - echo "Starting cron..." - supervisorctl start cron >/dev/null - - echo "Starting openssh server..." - supervisorctl start sshd >/dev/null - - echo "Starting nginx..." - supervisorctl start nginx >/dev/null - # due to the nature of docker and its use cases, we allow some time # for the database server to come online. case "${DB_TYPE}" in @@ -675,12 +661,6 @@ appStart () { echo "Creating satellites..." sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production >/dev/null - echo "Starting unicorn..." - supervisorctl start unicorn >/dev/null - - echo "Starting sidekiq..." - supervisorctl start sidekiq >/dev/null - # setup cron job for automatic backups case "${GITLAB_BACKUPS}" in daily) @@ -696,25 +676,9 @@ EOF esac crontab -u git /tmp/cron.git 2>/dev/null && rm -rf /tmp/cron.git - # watch the access logs - tail -F /var/log/nginx/gitlab_access.log -} - -appStop() { - echo "" - echo "Stopping unicorn..." - supervisorctl stop unicorn >/dev/null - echo "Stopping sidekiq..." - supervisorctl stop sidekiq >/dev/nul - echo "Stopping crond..." - supervisorctl stop cron >/dev/null - echo "Stopping sshd..." - supervisorctl stop sshd >/dev/null - echo "Stopping nginx..." - supervisorctl stop nginx >/dev/null - echo "Stopping supervisord..." - kill -15 $(cat /var/run/supervisord.pid) - exit + # start supervisord + echo "Starting supervisord..." + exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf } appSanitize () { diff --git a/assets/setup/install b/assets/setup/install index 2e9e66c1..f54d4e7c 100755 --- a/assets/setup/install +++ b/assets/setup/install @@ -126,7 +126,7 @@ directory=/home/git/gitlab environment=HOME=/home/git command=bundle exec unicorn_rails -c ${GITLAB_INSTALL_DIR}/config/unicorn.rb -E production user=git -autostart=false +autostart=true autorestart=true stopsignal=QUIT stdout_logfile=/var/log/supervisor/%(program_name)s.log @@ -150,7 +150,7 @@ command=bundle exec sidekiq -P ${GITLAB_INSTALL_DIR}/tmp/pids/sidekiq.pid -L ${GITLAB_INSTALL_DIR}/log/sidekiq.log user=git -autostart=false +autostart=true autorestart=true stdout_logfile=/var/log/supervisor/%(program_name)s.log stderr_logfile=/var/log/supervisor/%(program_name)s.log @@ -163,7 +163,7 @@ cat > /etc/supervisor/conf.d/sshd.conf <