- Anúncio -
- Anúncio -
Após configurar o seu servidor HHVM e após algum tempo de uso você pode receber a mensagem de “502 bad gateway“.
Esse problema ocorre devido algum bug do HHVM que ainda não consegui descobrir, porém você pode solucionar o problema executando um script que vai checar a cada minuto se o serviço HHVM está operando normalmente.
crie um arquivo chamado checkHHVM.sh com o script abaixo:
#!/bin/bash #ver. 4 ##this script will check mysql and apache ##if that service is not running ##it will start the service and send an email to you ##if the restart does not work, it sends an email and then exits ##set the path ##this works for Ubuntu 14.04 and 16.04 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ##set your email address EMAIL="[email protected]" ##list your services you want to check SERVICES=( 'hhvm' ) #### OK. STOP EDITING #### for i in "${SERVICES[@]}" do ###CHECK SERVICE#### `pgrep $i >/dev/null 2>&1` STATS=$(echo $?) ###IF SERVICE IS NOT RUNNING#### if [[ $STATS == 1 ]] then ##TRY TO RESTART THAT SERVICE### service $i start ##CHECK IF RESTART WORKED### `pgrep $i >/dev/null 2>&1` RESTART=$(echo $?) if [[ $RESTART == 0 ]] ##IF SERVICE HAS BEEN RESTARTED### then ##REMOVE THE TMP FILE IF EXISTS### if [ -f "/tmp/$i" ]; then rm /tmp/$i fi ##SEND AN EMAIL### MESSAGE="$i was down, but I was able to restart it on on $(hostname) $(date) " SUBJECT="$i was down -but restarted- on $(hostname) $(date) " echo $MESSAGE else ##IF RESTART DID NOT WORK### ##CHECK IF THERE IS NOT A TMP FILE### if [ ! -f "/tmp/$i" ]; then ##CREATE A TMP FILE### touch /tmp/$i ##SEND A DIFFERENT EMAIL### MESSAGE="$i is down on $(hostname) at $(date) " SUBJECT=" $i down on $(hostname) $(date) " echo $MESSAGE " I tried to restart it, but it did not work" fi fi fi done exit 0;
Salve.
de permissão para executar:
chmod 777 checkHHVM.sh
agora coloque para rodar em seu crontab
crontab -e
*/1 * * * * bash /local/do/arquivo/checkHHVM.sh >> /var/log/cron
agora ele vai checar a cada minuto se o serviço hhvm está ativo, caso não esteja ele reinicia automaticamente.
- Anúncio -
Consegui resolver fazendo essa configuração no nginx.conf
http {
#My custom settings
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
client_max_body_size 24M;
client_body_buffer_size 128k;
…
}
fonte: https://developernote.com/2012/09/how-i-fixed-nginx-502-bad-gateway-error/