Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch script deleting PID file before stopping the service #4369

Closed
pmvilaca opened this issue Nov 2, 2015 · 0 comments
Closed

Launch script deleting PID file before stopping the service #4369

pmvilaca opened this issue Nov 2, 2015 · 0 comments
Milestone

Comments

@pmvilaca
Copy link

pmvilaca commented Nov 2, 2015

We're now using the launch script that is being created by spring boot to manage the start/stop of our services (integrated with AWS Code Deploy). But sometimes, we're getting some deployment failures because the application didn't stop and the tomcat port is still in use.

Looking at the script, I think that the rm -f "$pid_file" in the stop method isn't correct because the PID file is being deleted before stopping the application.

Although, the do_stop method looks fine because it's triggering the shutdown and waiting until the application is stopped to delete the PID file, so the fix for this issue will just delete the additional line in the stop method.

Or am I missing something?

stop() {
  [[ -f $pid_file ]] || { echoYellow "Not running (pidfile not found)"; return 0; }
  pid=$(cat "$pid_file")
  rm -f "$pid_file"
  isRunning $pid || { echoYellow "Not running (process ${pid} not found)"; return 0; }
  do_stop $pid $pid_file
}

do_stop() {
  kill -HUP $1 &> /dev/null || { echoRed "Unable to kill process $1"; return 1; }
  for i in $(seq 1 60); do
    isRunning $1 || { echoGreen "Stopped [$1]"; rm -f $2; return 0; }
    sleep 1
  done
  echoRed "Unable to kill process $1";
  return 1;
}
pmvilaca pushed a commit to pmvilaca/spring-boot that referenced this issue Nov 2, 2015
The pid file was being removed at the beginning of the stop method and when the service
wasn't able to stop during the first run, it wasn't possible to use the launch script anymore

Fixes spring-projectsgh-4369
pmvilaca pushed a commit to pmvilaca/spring-boot that referenced this issue Nov 3, 2015
When a pid file is present but the process isn't running, we
still need to remove the (stale) pid file.

 Fixes spring-projectsgh-4369
pmvilaca pushed a commit to pmvilaca/spring-boot that referenced this issue Nov 3, 2015
@philwebb philwebb added this to the 1.3.0 milestone Nov 5, 2015
philwebb referenced this issue Nov 10, 2015
* pr/4371:
  Don't remove PID file before stopping the service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants