#path project_path=$(cd `dirname $0`; cd ..; pwd) pid_file=${project_path}/bin/pid echo "INFO: project_path=${project_path}" echo "INFO: pid_file=${pid_file}" if [[ -f $pid_file ]]; then pid=$(cat $pid_file); else echo "INFO: STOPPED"; echo "INFO: The service is already stopped. Cannot find the file $pid_file."; exit 0; fi if [[ -z "$pid" || ! -d /proc/$pid ]]; then echo "INFO: STOPPED"; echo "INFO: The service' is already stopped. Cannot find its process."; rm -rf $pid_file; exit 0; fi if [[ ! -O /proc/$pid ]]; then echo "Error: the process with id $pid of the service is not owned by the user $USER." > /dev/stderr; exit 1; fi if kill -9 $pid; then rm -rf $pid_file; echo "INFO:service STOPPED"; else echo "Error when stopping the service." > /dev/stderr; exit 1; fi