MAIS

    Resolvendo problema “502 bad gateway” HHVM

    - 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 -

    Artigos recentes

    Continue lendo

    1 COMENTÁRIO

    DEIXE UMA RESPOSTA

    Please enter your comment!
    Please enter your name here