I’m trying to call the command sudo mender -install /path/to/artifact.mender from a subprocess.
The command is working and it executes the update, but it hangs at 100% so it won’t finish with “Done” like when I execute it directly in the terminal
command in terminal: sudo mender -install /path/to/artifact.mender
output in terminal: INFO[0000] no public key was provided for authenticating the artifact module=installer ................................ 10% 1024 KiB ................................ 21% 2048 KiB ................................ 31% 3072 KiB ................................ 42% 4096 KiB ................................ 52% 5120 KiB ................................ 63% 6144 KiB ................................ 74% 7168 KiB ................................ 84% 8192 KiB ................................ 95% 9216 KiB .............. 100% 9670 KiB Use -commit to update, or -rollback to roll back the update.
It seems like I’ve found the problem, but no solution to solve this.
I’m starting the script from “node-red” which creates a child process and this child process is not completely detached from the parent process, which is “node-red”. So the script then starts the mender installer and the update module does the following: stops node-red, copy unzipped files to the new directory and starts node-red again. At the time the node-red instance is stopped, the mender updater stops to work because the command is triggered by the parent process.
I thought that nohup will solve this problem by detaching the process from the child. I also tried it with disown or also with a Node.JS Application, which creates a child process and then detaches this process.
But nothing seems to work .
If it’s a systemd system, you could try using systemd-run, which will put the process in its own cgroup. It’s sometimes a bit tricky to get it to do the right thing though, you may need to experiment with some arguments (maybe -P or --scope) to get the right behavior. The man page is your friend.
Ok I’m confused now.
If I run mender in daemon-mode, how I then call the client to trigger a mender update?
I was just only using mender as a “command” and triggered it from console, but now I need some more automatic logic to call the updater based on some events.
I always thought the daemon mode is only useful, when it’s used in managed mode with mender server. But we don’t use a mender server. The devices are running all standalone.
Ok I’ve found a workaround.
The problem is, that I can’t detach the mender command from the node-red parent process. So and if the update process run, the node-red service is stopped, which affects the mender installation process as a child process it self.
I also tried to detach the process with different methods, like fork and also as subprocess with python.
Now I’ve written an FIFO listener which listen to commands and triggers the mender update procedure.
The listener is written in python and is running as a deamon process on startup.
From node-red I’m pushing the command to the running listener which than executes the mender update process. This seems to work stable, but still needs also some security handling.
If someone is interested in this, I can share it, but I think this is a bit off-topic and has nothing to do with mender it self.