0

I have upstart configuration for my java process:

/etc/init/myjar.conf

description "my jar"
author "me"

start on runlevel [2345]
stop on shutdown

expect fork

script
    chdir /opt/myjar/
    java -jar myjar.jar >/var/log/myjar/myjar.log 2>&1
end script

post-start script
    emit myjar-local_running
end script

The service works fine, apart from the following scenario:

  1. process is killed from outside, i.e: killall java
  2. trying to stop the service: sudo service myjar stop <--- hanging......

The process is in the following state:

myjar start/killed, process 123

Can't restart it either...

Any help would be appreciated.

11
  • 1
    Unrelated, but general suggestions: Use a chdir stanza instead of doing a cd in the script stanza, and use a post-start script stanza to emit the signal instead of using the main script stanza.
    – muru
    Oct 29, 2014 at 0:21
  • 1
    Possibly related: Are you sure the process forks? If so, does it fork exactly once? Could you try with expect daemon?
    – muru
    Oct 29, 2014 at 0:26
  • 1
    @Godsaur And without an expect line at all? (The chdir line goes above the script line, btw.)
    – muru
    Oct 29, 2014 at 0:56
  • 1
    @muru, may be the problem is cd command as reported in comment 5 of this bug
    – Lety
    Oct 29, 2014 at 0:56
  • 1
    @muru, Thank you for your honesty, but would not be a problem if you wrote an answer using my comments. I addressed to you my comments because I wanted to share the information in order to find the solution quickly... I was going to sleep :)
    – Lety
    Oct 29, 2014 at 12:11

1 Answer 1

3

According to upstart manual expect fork:

   Upstart will expect the process executed to call fork(2) exactly once.

and according to comment 5 in init: job stuck with expect fork/daemon when parent reaps child bug:

when you use "expect fork" or "expect daemon" combined with "script", Upstart ends up following the first spawned child whose exit status is reaped by the shell.

In your case, upstart probably follows chdir pid.

Your upstart script seems a task job because neither chdir nor java command fork, so, removing expect fork should fix the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .