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.