My .NET application runs on Linux (usually a Raspberry Pi) and is installed as a Debian package. Now the application shall be able to upgrade itself when it receives a network command to do so. This is probably a complicated thing because the external upgrade script performs these steps:
- download the current Debian package file from the internet (might take a few minutes)
- run
apt-get install
to install the downloaded package file, with all options to not stop and ask any questions - delete the downloaded package file
That upgrade script already exists and works fine when run interactively from the local shell. Now it shall be started by the app itself, non-interactively.
As part of the package scripts, the application service itself will be terminated and later restarted. So the app can’t wait for the upgrade to complete because it doesn’t live to see it.
If I simply start a new process, I can’t wait for it. Will it still continue to run when the starting (parent) process exited? Do I need to start the upgrade script in the background somehow, using command &
or systemd-run
with some arguments?
This is my simple starting point:
var psi = new ProcessStartInfo
{
FileName = "/usr/local/bin/upgrade-app.sh",
CreateNoWindow = true
};
var process = Process.Start(psi);