deivisonarthur
7/18/2013 - 10:28 PM

Magento Daemon - restart/stop/status services nginx/varnish/php-fpm/memcached - Entrar em /etc/rc.d/init.d/ ou /etc/init.d e criar o arquivo

Magento Daemon - restart/stop/status services nginx/varnish/php-fpm/memcached - Entrar em /etc/rc.d/init.d/ ou /etc/init.d e criar o arquivo magento com touch com os seguintes parametros

#!/bin/bash
#
# magento - this script starts and stops the magento daemon
#
# chkconfig:   - 85 15
# description:  magento is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: magento
# pidfile:     /var/run/magento.pid
#
# script by: Samuel Maciel Sampaio <samukasmk@gmail.com> [20140110]
#
# Source function library.
#. /etc/rc.d/init.d/functions
#
# Source networking configuration.
#. /etc/sysconfig/network
#
# Check that networking is up.
#[ "$NETWORKING" = "yes" ] && exit 0


function magento_services(){
    local action=$1
    local specific_service=$2

    if [ ! -z "$specific_service" ];
    then
        sudo service $specific_service $action
    else
        sudo service hhvm restart
        sudo service nginx $action
        sudo service varnish $action
    fi
}

function magento_services_all(){
    local action=$1
    local specific_service=$2

    if [ ! -z "$specific_service" ];
    then
        sudo service $specific_service $action
    else
        sudo service hhvm restart
        sudo service nginx $action
        #sudo service redis-server restart
        sudo service varnish $action
        #sudo service redis-server $action
        #sudo redis-cli FLUSHALL
        echo "  Aplicando comando: sudo chown -R www-data:www-data /mnt/www/oculosNew/"
        sudo chown -R www-data:www-data /mnt/www/oculosNew/*
        echo -e "\e[32m ✓ chown aplicado com sucesso!" # \033[32m✓\033[0m\n   033[31m✗\033[0m\n

        echo -e "\e[39m Aplicando comando: sudo chmod -R g+w /mnt/www/oculosNew/"
        sudo chmod -R g+w /mnt/www/oculosNew/*
        echo -e "\e[32m ✓ chmod aplicado com sucesso!"

        echo -e "\e[39m"
    fi
}

function magento_services_redis(){
    local action=$1
    local specific_service=$2

    if [ ! -z "$specific_service" ];
    then
        sudo service $specific_service $action
    else
        #sudo service php5-fpm restart
        sudo service hhvm restart
        sudo service nginx restart
        sudo service varnish restart
        #sudo service redis-server restart
        #sudo redis-cli FLUSHALL
        #sudo chown -R www-data:www-data /mnt/www/oculosNew/
        #sudo chmod -R g+w /mnt/www/oculosNew/
    fi
}

#mencached - disabled

#FILE_LOCAL_XML="/mnt/www/oculosNew/app/etc/local.xml"

#function flush_memcached(){
    #local memcached_ip=$(cat "$FILE_LOCAL_XML" | grep tcp | tr '\/:?' ' ' | awk '{print $2}')
    #local memcached_port=$(cat "$FILE_LOCAL_XML" | grep tcp | tr '\/:?' ' ' | awk '{print $3}')
    #echo -n '* Flushing Memcached: '
    #echo 'flush_all' | nc $memcached_ip $memcached_port
#}


case $1 in
        start)     magento_services $1 $2;;
        stop)      magento_services $1 $2;;
        status)    magento_services $1 $2;;
        reload)    magento_services $1 $2;;
        restart)   magento_services $1 $2;;
        all)       magento_services_all $1 $2;;
        redis)     magento_services_redis $1 $2;;



        *)         if [ -z "$1" ];
                   then
                       echo -e "Missing Arguments !\n\nUsage:  $0 <start|stop|status|restart|all> [service]"
                       else
                           echo -e "Invalid Arguments ($@) !\n\nUsage:  $0 <start|stop|status|restart|all> [service]"
                   fi;;
esac
#!/bin/sh
#
# magento - this script starts and stops the magento daemon
#
# chkconfig:   - 85 15
# description:  magento is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: magento
# pidfile:     /var/run/magento.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

case $1 in
        restart) sudo service php-fpm $1 && sudo service nginx $1 && sudo service varnish $1  && sudo service memcached $1;;
        start)   sudo service php-fpm $1 && sudo service nginx $1 && sudo service varnish $1  && sudo service memcached $1;;
        stop)    sudo service php-fpm $1 && sudo service nginx $1 && sudo service varnish $1  && sudo service memcached $1;;
        status)  sudo service php-fpm $1 && sudo service nginx $1 && sudo service varnish $1  && sudo service memcached $1;;
esac