Distillery: "Node is not running!" and non-zero exit code

Hi,

If I start the build with _build/prod/rel/projectname/bin/projectname foreground and then stop it with_build/prod/rel/projectname/bin/projectname stop I get the error message: “Node is not running!” and the exit code 1. The shutdown seems to work nonetheless, at least I don’t see any beam processes other than epmd lurking around, but I don’t want to just ignore the error since I use systemd to start and stop the processes. If processes exit with a non-zero exit code, systemd marks the unit as failed.

Perhaps the foreground option is not meant to be used with the stop command, but sending SIGINT or SIGTERM to the process instead doesn’t solve my problem either: The error message “Node ist not running!” disappears, but I still get a non-zero exit code. Starting the process with “start” instead of foreground is also not an option, since I want the log messages to appear in my systemd journal.

I’d appreciate any advice to solve this without workarounds such as adding SuccessExitStatus= to the systemd service file.

1 Like

stop is meant as a counterpart to start - in my own applications where I use foreground I send SIGTERM to the bin/projectname script process, not the beam.smp process. This is because the script sets up a trap to ensure the application terminates gracefully. If you send SIGTERM directly to the beam.smp process, it will shutdown, but not gracefully, and the trap will then be executed which is what is generating the Node is not running message (because it can’t rpc to the node to tell it to stop).

2 Likes

I see. In that case, I suppose adding SuccessExitStatus=143 to the systemd service file is the best solution. I thought it was more of a workaround than a fix, but it seems this is a common approach for Java applications as well.

2 Likes