Score:0

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

cn flag

In the python flask example application given on https://nixos.org/guides/dev-environment.html ... 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 myapp.py >> /dev/null 2>&1 &
pid=$!

# ok so we have the pid

if [[ $(curl --retry 3 --retry-delay 1 --retry-connrefused http://127.0.0.1:5000) == "Hello, Nix!" ]]; then
    echo "SUCCESS: myapp.py is serving the expected string"
    # and if the health check runs successfully, we kill the python process
    kill $pid
    exit 0
else
    echo "FAIL: myapp.py is not serving the expected string"
    # and if the health check fails, we kill the python process
    kill $pid
    exit 1
fi
Score:0
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.

mangohost

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.