Last active
August 29, 2015 14:09
-
-
Save lysenkooo/5cb5d363d35a40c05712 to your computer and use it in GitHub Desktop.
CentOS Configurations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: bucardo | |
# Required-Start: $remote_fs $syslog postgresql-9.3 | |
# Should-Start: postgresql-9.3 | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Manage bucardo | |
# Description: Start, stop, restart bucardo | |
### END INIT INFO | |
run () { | |
eval $1 | |
} | |
case "$1" in | |
start) | |
run "/usr/local/bin/bucardo --log-destination /var/log/bucardo start" | |
;; | |
stop) | |
run "/usr/local/bin/bucardo stop" | |
;; | |
force-stop) | |
run "/usr/local/bin/bucardo stop" | |
;; | |
restart|reload) | |
run "/usr/local/bin/bucardo --log-destination /var/log/bucardo restart" | |
;; | |
upgrade) | |
echo >&2 "Couldn't upgrade, starting '$CMD' instead" | |
run "/usr/local/bin/bucardo upgrade" | |
;; | |
reopen-logs) | |
echo >&2 "Not supported" | |
;; | |
*) | |
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>" | |
exit 1 | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbport = 5432 | |
dbhost = 127.0.0.1 | |
dbname = bucardo | |
dbuser = bucardo | |
dbpass = bucardo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * pgrep lsyncd > /dev/null; if [ $? -ne 0 ]; then /usr/local/bin/lsyncd /etc/lsyncd.conf; fi | |
* * * * * ps ax | grep -v 'grep' | grep 'resque' > /dev/null; if [ $? -ne 0 ]; then su - docs -c 'cd /www/docs/current && rake resque:work RAILS_ENV=production QUEUE=paperclip'; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settings { | |
logfile = "/www/docs/shared/log/lsyncd.log", | |
statusFile = "/www/docs/shared/log/lsyncd-status.log", | |
statusInterval = 10, | |
-- nodaemon = true, | |
} | |
sync { | |
default.rsyncssh, | |
source="/www/docs/shared/public/doco/system", | |
host="docs@10.213.0.46", | |
targetdir="/www/docs/shared/public/doco/system", | |
-- rsync = { | |
-- rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no -i /home/docs/.ssh/id_rsa", | |
-- } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream docs_backend { | |
#server 127.0.0.1:3000; | |
#server 127.0.0.1:3001; | |
#server 127.0.0.1:3002; | |
server unix:/tmp/unicorn.docs.sock fail_timeout=0; | |
} | |
upstream db24_node { | |
server 10.213.0.46:80; | |
} | |
server { | |
listen 80 default_server; | |
server_name docs.rcntec.com; | |
root /www/docs/current/public; | |
location / { | |
try_files $uri @app; | |
} | |
location /doco/system/ { | |
try_files $uri @db24; | |
} | |
location /doco/assets/ { | |
access_log off; | |
expires 1d; | |
} | |
location @app { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://docs_backend; | |
} | |
location @db24 { | |
if ($http_x_mirror_request) { return 404; } | |
proxy_pass http://db24_node; | |
proxy_set_header X-Mirror-Request 1; | |
proxy_intercept_errors on; | |
} | |
client_max_body_size 100m; | |
error_log /www/docs/shared/log/nginx_error.log debug; | |
access_log /www/docs/shared/log/nginx_access.log; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $remote_fs postgresql-9.3 | |
# Required-Stop: $remote_fs postgresql-9.3 | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Manage unicorn server | |
# Description: Start, stop, restart unicorn server for a specific application. | |
### END INIT INFO | |
set -e | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
APP_ROOT=/www/docs/current | |
RVM_TYPE=auto | |
PID=/www/docs/current/tmp/pids/unicorn.pid | |
if [ "$RVM_TYPE" == "system" ]; then | |
CMD="cd /www/docs/current; rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'bundle exec unicorn -D -c /www/docs/current/config/unicorn.rb -E production'" | |
else | |
CMD="cd /www/docs/current; source \"/home/docs/.rvm/environments/default\"; bundle exec unicorn -D -c /www/docs/current/config/unicorn.rb -E production" | |
fi | |
AS_USER=docs | |
set -u | |
OLD_PIN="$PID.oldbin" | |
sig () { | |
test -s "$PID" && kill -$1 `cat $PID` | |
} | |
oldsig () { | |
test -s $OLD_PIN && kill -$1 `cat $OLD_PIN` | |
} | |
run () { | |
if [ "$(id -un)" = "$AS_USER" ]; then | |
eval $1 | |
else | |
su -c "$1" - $AS_USER | |
fi | |
} | |
case "$1" in | |
start) | |
sig 0 && echo >&2 "Already running" && exit 0 | |
run "$CMD" | |
;; | |
stop) | |
sig QUIT && exit 0 | |
echo >&2 "Not running" | |
;; | |
force-stop) | |
sig TERM && exit 0 | |
echo >&2 "Not running" | |
;; | |
restart|reload) | |
sig USR2 && echo reloaded OK && exit 0 | |
echo >&2 "Couldn't reload, starting '$CMD' instead" | |
run "$CMD" | |
;; | |
upgrade) | |
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT | |
then | |
n=$TIMEOUT | |
while test -s $OLD_PIN && test $n -ge 0 | |
do | |
printf '.' && sleep 1 && n=$(( $n - 1 )) | |
done | |
echo | |
if test $n -lt 0 && test -s $OLD_PIN | |
then | |
echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds" | |
exit 1 | |
fi | |
exit 0 | |
fi | |
echo >&2 "Couldn't upgrade, starting '$CMD' instead" | |
run "$CMD" | |
;; | |
reopen-logs) | |
sig USR1 | |
;; | |
*) | |
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment