提交 5ac5f586 编写于 作者: D Dmitriy Zaporozhets

Move init.d and nginx default recipes in core library to save efforts trying...

Move init.d and nginx default recipes in core library to save efforts trying keep sync between gitlab-recipes and gitlabhq
上级 cbcfe12f
......@@ -200,7 +200,7 @@ Make sure to update username/password in config/database.yml.
Download the init script (will be /etc/init.d/gitlab):
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
Make GitLab start on boot:
......@@ -241,7 +241,7 @@ If you can't or don't want to use Nginx as your web server, have a look at the
Download an example site config:
sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab
sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/nginx/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
Make sure to edit the config file to match your setup:
......
#! /bin/bash
# GITLAB
# Maintainer: @randx
# App Version: 5.1
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
APP_ROOT="/home/git/gitlab"
DAEMON_OPTS="-C $APP_ROOT/config/puma.rb -e production"
PID_PATH="$APP_ROOT/tmp/pids"
WEB_SERVER_PID="$PID_PATH/puma.pid"
SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
START_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:start"
NAME="gitlab"
DESC="Gitlab service"
check_pid(){
if [ -f $WEB_SERVER_PID ]; then
PID=`cat $WEB_SERVER_PID`
SPID=`cat $SIDEKIQ_PID`
STATUS=`ps aux | grep $PID | grep -v grep | wc -l`
else
STATUS=0
PID=0
fi
}
start() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
# Program is running, exit with error code 1.
echo "Error! $DESC $NAME is currently running!"
exit 1
else
if [ `whoami` = root ]; then
sudo -u git -H bash -l -c "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
echo "$DESC started"
fi
fi
}
stop() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
## Program is running, stop it.
kill -QUIT `cat $WEB_SERVER_PID`
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
rm "$WEB_SERVER_PID" >> /dev/null
echo "$DESC stopped"
else
## Program is not running, exit with error.
echo "Error! $DESC not started!"
exit 1
fi
}
restart() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..."
kill -USR2 `cat $WEB_SERVER_PID`
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &"
if [ `whoami` = root ]; then
sudo -u git -H bash -l -c "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
fi
echo "$DESC restarted."
else
echo "Error, $NAME not running!"
exit 1
fi
}
status() {
cd $APP_ROOT
check_pid
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "$DESC / Unicorn with PID $PID is running."
echo "$DESC / Sidekiq with PID $SPID is running."
else
echo "$DESC is not running."
exit 1
fi
}
## Check to see if we are running as root first.
## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload|force-reload)
echo -n "Reloading $NAME configuration: "
kill -HUP `cat $PID`
echo "done."
;;
status)
status
;;
*)
echo "Usage: sudo service gitlab {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0
# GITLAB
# Maintainer: @randx
# App Version: 5.0
upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}
server {
listen YOUR_SERVER_IP:80 default_server; # e.g., listen 192.168.1.1:80;
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
root /home/git/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册