Created
January 25, 2013 14:10
-
-
Save netojoaobatista/4634714 to your computer and use it in GitHub Desktop.
Template para criação de um inicializador de serviços
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 | |
prog=php | |
#função para iniciar o serviço | |
start() { | |
echo -n $"iniciando $prog..." | |
# aqui o código para iniciar alguma coisa, por exemplo: | |
php -S localhost:8080 >php_log & | |
} | |
#função para parar o serviço | |
stop() { | |
echo -n $"parando $prog..." | |
pid=`ps -o pid,command ax | grep $prog | awk '!/awk/ && !/grep/ {print $1}'`; | |
if [ "${pid}" != "" ]; then | |
kill -2 ${pid}; | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Use: $prog {start|stop}" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment