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
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5

expect fork

    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
  • Are you literally running service stop myservice? – TheWanderer Oct 9 '16 at 17:55
  • 1
    Oops should be service myservice stop – Xi Zhang Oct 9 '16 at 18:13
  • The issue I'm concerned about is whether or not you are literally using myservice (which is a placeholder for the service you are trying to control, not an actual service). – TheWanderer Oct 9 '16 at 18:17
  • I am literally using myservice. So what should I use for the real service? – Xi Zhang Oct 9 '16 at 18:29
  • Ah, this is why I was confused. How long have you waited during that terminal hang? – TheWanderer Oct 9 '16 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.