I have a /etc/init/myservice.conf. On reboot, it's up and running with no issues. The service is a java web server, e.g.:
java -jar myhttpserver.jar
But! I cannot manually stop or restart the service. If I do:
service myservice stop
Then the terminal hangs. If I Ctrl+C and try again, it tells me stop: Job has already been stopped: myservice. I think it's lying because I can still access the it using a web browser. initctl list shows this:
myservice stop/killed, process 1303
Why it cannot be stopped? How do I manually restart it? I want to test the sever by replacing the jar and restarting service.
FWIW, it's a Google Compute Engine instance with Ubuntu 14. The conf file:
description "server instances"
author "Me"
start on runlevel [2345]
stop on shutdown
#Respawn the process if it crashes
respawn
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5
expect fork
script
logPath="/var/log/myservice"
mkdir -p $logPath
logFile="/"$logPath"/"$(date +'%Y-%m-%d-%H-%M-%S')
java -cp /home/myuser/dev.jar com.myservice.Main dev > $logFile"_dev_std" 2> $logFile"_dev_err"
end script