Recebi a tarefa de colocar uma instância do chiliproject online novamente. Ele está sendo executado em um servidor do CentOS 6 (64 bits). O problema é que eu sei absolutamente zero Ruby, e meu conhecimento de Linux não é muito mais avançado do que isso; Não tenho a menor ideia de por onde começar.
Quando carrego a página em um navegador, o seguinte é gravado em /var/log/nginx/redmine-proxy-error
:
2014/01/13 11:52:06 [crit] 1865#0: *675 connect() to unix:/var/run/redmine/sockets/thin.3.sock failed (2: No such file or directory) while connecting to upstream, client: IPADDRESSHERE, server: REDACTED.com.br, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/redmine/sockets/thin.3.sock:/", host: "REDACTED.com.br"
2014/01/13 11:52:06 [crit] 1865#0: *675 connect() to unix:/var/run/redmine/sockets/thin.0.sock failed (2: No such file or directory) while connecting to upstream, client: IPADDRESSHERE, server: REDACTED.com.br, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/redmine/sockets/thin.0.sock:/", host: "REDACTED.com.br"
2014/01/13 11:52:06 [crit] 1865#0: *675 connect() to unix:/var/run/redmine/sockets/thin.1.sock failed (2: No such file or directory) while connecting to upstream, client: IPADDRESSHERE, server: REDACTED.com.br, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/redmine/sockets/thin.1.sock:/", host: "REDACTED.com.br"
2014/01/13 11:52:06 [crit] 1865#0: *675 connect() to unix:/var/run/redmine/sockets/thin.2.sock failed (2: No such file or directory) while connecting to upstream, client: IPADDRESSHERE, server: REDACTED.com.br, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/redmine/sockets/thin.2.sock:/", host: "REDACTED.com.br"
Eu recebi ajuda do #chiliproject no IRC:
thin
is an app server which (in your case) seems to be tasked to run the actual chiliproject code. It has to be started seperately from nginx, and should then (according to your config) create a listening socket at /var/run/redmine/sockets/thin.3.sock where your nginx forwards connections to. You might have a seperate init script for thin already. Or else you might have to start it using script/server or the thin executable inside your chiliproject dir. You probably have a thin config file somewhere (something like redmine.yml, e.g. in /etc/thin), it should contain (in human readable form) some config settings for thin, including the socket location, your chiliproject directory and other stuff. You can start thin by running thin start -C /etc/thin/redmine.yml
Aqui está o meu /etc/thin/redmine.yml
(o único arquivo neste diretório):
---
chdir: /srv/www/redmine/chiliproject
environment: production
timeout: 30
log: /var/log/redmine/thin.log
pid: /var/run/redmine/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 30
servers: 4
socket: /var/run/redmine/sockets/thin.sock
daemonize: true
user: redmine
group: redmine
E aqui está o /etc/rc.d/init.d/thin
:
#!/usr/bin/env sh
### BEGIN INIT INFO
# Provides: thin
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: thin initscript
# Description: thin
### END INIT INFO
# Original author: Forrest Robertson
# Do NOT "set -e"
DAEMON=/usr/local/rvm/gems/ruby-1.9.2-p290/bin/thin
#DAEMON=/usr/local/rvm/bin/bootup_thin
SCRIPT_NAME=/etc/init.d/thin
#CONFIG_PATH=/etc/thin
CONFIG_PATH=/etc/thin/redmine.yml
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
#$DAEMON start --all $CONFIG_PATH
$DAEMON start -C /etc/thin/redmine.yml
;;
stop)
$DAEMON stop --all $CONFIG_PATH
;;
restart)
$DAEMON restart --all $CONFIG_PATH
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
exit 3
;;
esac
:
Não há arquivo /usr/local/rvm/bin/bootup_thin
.
Eu reinicio a máquina e executo ps aux | grep thin
não me mostra nada (além do próprio grep).
Se eu executar start -C /etc/thin/redmine.yml
, obtenho uma saída de texto na tela e inicio em thin e posso navegar pelo site. Se eu reiniciar a máquina, o serviço não será carregado corretamente, apesar do arquivo init.d
. Este arquivo está sendo executado, porque eu coloquei uma linha touch /var/log/test
na cláusula start)
e o arquivo foi criado. Eu também adicionei > /var/log/thin_output
ao final da linha de partida, mas ele cria e arquiva o arquivo, e os thin
logs não mostram que ele está sendo iniciado.
Incluir start -C /etc/thin/redmine.yml
no final de /etc/rc.local
também não tem efeito.
A saída de type thin
é
thin is /usr/local/rvm/gems/ruby-1.9.2-p290/bin/thin
Se eu digitar /etc/init.d/thin start
, ele será iniciado com uma saída normal:
Starting server on /var/run/redmine/sockets/thin.0.sock ...
Starting server on /var/run/redmine/sockets/thin.1.sock ...
Starting server on /var/run/redmine/sockets/thin.2.sock ...
Starting server on /var/run/redmine/sockets/thin.3.sock ...
Foi-me perguntado no chat para colar a saída de find -L /etc/ -samefile /etc/init.d/thin
, é:
/etc/rc2.d/K50thin
/etc/rc0.d/K50thin
/etc/rc5.d/K50thin
/etc/init.d/thin
/etc/rc.d/rc2.d/K50thin
/etc/rc.d/rc0.d/K50thin
/etc/rc.d/rc5.d/K50thin
/etc/rc.d/init.d/thin
/etc/rc.d/rc3.d/K50thin
/etc/rc.d/rc1.d/K50thin
/etc/rc.d/rc4.d/K50thin
/etc/rc.d/rc6.d/K50thin
/etc/rc3.d/K50thin
/etc/rc1.d/K50thin
/etc/rc4.d/K50thin
/etc/rc6.d/K50thin
Eu executei sudo chkconfig thin on
como sugerido em uma resposta aqui e chkconfig -l thin
outputs
thin 0:off 1:off 2:on 3:on 4:on 5:on 6:off
e a saída de find -L /etc/ -samefile /etc/init.d/thin
muda para /etc/rc2.d/S50thin /etc/rc0.d/K50thin /etc/rc5.d/S50thin /etc/init.d/thin /etc/rc.d/rc2.d/S50thin /etc/rc.d/rc0.d/K50thin /etc/rc.d/rc5.d/S50thin /etc/rc.d/init.d/thin /etc/rc.d/rc3.d/S50thin /etc/rc.d/rc1.d/K50thin /etc/rc.d/rc4.d/S50thin /etc/rc.d/rc6.d/K50thin /etc/rc3.d/S50thin /etc/rc1.d/K50thin /etc/rc4.d/S50thin /etc/rc6.d/K50thin
; mas quando eu reinicio, o thin ainda não está rodando.
Alguém sugeriu que eu comparasse as variáveis de ambiente em diferentes níveis de execução, então incluí printenv > /var/log/printenv.log
em uma linha de /etc/rc.d/init.d/thin
e a comparei com a saída de printenv
na CLI. Aqui estão os resultados:
TERM=linux
PATH=/sbin:/usr/sbin:/bin:/usr/bin
RUNLEVEL=3
runlevel=3
PWD=/
LANGSH_SOURCED=1
LANG=pt_BR.UTF-8
PREVLEVEL=N
previous=N
CONSOLETYPE=vt
SHLVL=2
UPSTART_INSTANCE=
UPSTART_EVENTS=runlevel
UPSTART_JOB=rc
_=/usr/bin/printenv
e
rvm_bin_path=/usr/local/rvm/bin
HOSTNAME=redacted.com.br
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.2-p290
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
IRBRC=/usr/local/rvm/rubies/ruby-1.9.2-p290/.irbrc
SSH_CLIENT=REDACTED
OLDPWD=/etc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-1.9.2-p290
SSH_TTY=/dev/pts/0
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
__array_start=0
rvm_path=/usr/local/rvm
escape_flag=1
rvm_prefix=/usr/local
MAIL=/var/spool/mail/root
PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1.9.2-p290@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PWD=/
XMODIFIERS=@im=ibus
LANG=pt_BR.utf8
_second=1
HISTCONTROL=ignoredups
rvm_version=1.16.17 (stable)
SHLVL=1
HOME=/root
_first=0
LOGNAME=root
CVS_RSH=ssh
GEM_PATH=/usr/local/rvm/gems/ruby-1.9.2-p290:/usr/local/rvm/gems/ruby-1.9.2-p290@global
SSH_CONNECTION=REDACTED
LESSOPEN=|/usr/bin/lesspipe.sh %s
RUBY_VERSION=ruby-1.9.2-p290
G_BROKEN_FILENAMES=1
_=/usr/bin/printenv