Skip to content

Instantly share code, notes, and snippets.

@netojoaobatista
Created January 25, 2013 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save netojoaobatista/4634714 to your computer and use it in GitHub Desktop.
Save netojoaobatista/4634714 to your computer and use it in GitHub Desktop.
Template para criação de um inicializador de serviços
#!/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