Merge branch 'launch-via-supervisord'

Refer #149
This commit is contained in:
Sameer Naik 2014-10-11 00:33:34 +05:30
commit 2c29d7fc29
2 changed files with 48 additions and 37 deletions

View File

@ -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
@ -668,12 +654,12 @@ appStart () {
rm -rf tmp/pids/unicorn.pid
rm -rf tmp/pids/sidekiq.pid
# start the gitlab application
sudo -u git -H /etc/init.d/gitlab start
# remove state unicorn socket if it exists
rm -rf tmp/sockets/gitlab.socket
# create satellite directories
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
echo "Creating satellites..."
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production >/dev/null
# setup cron job for automatic backups
case "${GITLAB_BACKUPS}" in
@ -690,22 +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 ""
/etc/init.d/gitlab stop
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 () {

View File

@ -118,6 +118,44 @@ cat > /etc/logrotate.d/supervisord <<EOF
}
EOF
# configure supervisord to start unicorn
cat > /etc/supervisor/conf.d/unicorn.conf <<EOF
[program:unicorn]
priority=10
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=true
autorestart=true
stopsignal=QUIT
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
EOF
# configure supervisord to start sidekiq
cat > /etc/supervisor/conf.d/sidekiq.conf <<EOF
[program:sidekiq]
priority=10
directory=/home/git/gitlab
command=bundle exec sidekiq
-q post_receive
-q mailer
-q system_hook
-q project_web_hook
-q gitlab_shell
-q common
-q default
-e production
-P ${GITLAB_INSTALL_DIR}/tmp/pids/sidekiq.pid
-L ${GITLAB_INSTALL_DIR}/log/sidekiq.log
user=git
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
EOF
# configure supervisor to start sshd
mkdir -p /var/run/sshd
cat > /etc/supervisor/conf.d/sshd.conf <<EOF
@ -125,7 +163,7 @@ cat > /etc/supervisor/conf.d/sshd.conf <<EOF
directory=/
command=/usr/sbin/sshd -D
user=root
autostart=false
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s_error.log
@ -138,7 +176,7 @@ priority=20
directory=/tmp
command=/usr/sbin/nginx -g "daemon off;"
user=root
autostart=false
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
@ -151,7 +189,7 @@ priority=20
directory=/tmp
command=/usr/sbin/cron -f
user=root
autostart=false
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log