NixOS starting a daemon process example - is the example broken?

cn flag

In the python flask example application given on ... Isn't it just killing the daemon process whether it passes the health check or not? Maybe there's something implicit going on that I'm not grasping?

You can also run a bash script like this one in your CI to make sure your default.nix keeps working in the future.

#!/usr/bin/env nix-shell
#! nix-shell -i bash
set -euo pipefail

# start myapp in background and save the process id
python >> /dev/null 2>&1 &

# ok so we have the pid

if [[ $(curl --retry 3 --retry-delay 1 --retry-connrefused == "Hello, Nix!" ]]; then
    echo "SUCCESS: is serving the expected string"
    # and if the health check runs successfully, we kill the python process
    kill $pid
    exit 0
    echo "FAIL: is not serving the expected string"
    # and if the health check fails, we kill the python process
    kill $pid
    exit 1
ua flag

That example isn't about starting a daemon to be a long-running service, but about starting a daemon as a short-lived CI check, to ensure things should still work when someone does want to start the long-running daemon.


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.