0

I’m running a dotnet application on a VPS running Ubuntu, and the application has to be running continuously 24/7. When I start up the application, I use “nohup dotnet (name).dll”, and in HTOP those processes will simply have the command “dotnet (name).dll” attached to them. However, because of the nature of the application, it has to run in multiple processes, meaning multiple PIDs. I’ve seen multiple examples of restarting processes if they crash, but they all seem to be based on PIDs from what I’ve seen. What kind of script would I need that would look for “dotnet” commands that stop running and run several lines of code (including a sleep command so that it doesn’t restart the process again while it’s already starting up), and how would I go about making sure that it constantly runs in the background?

1
  • You should write a program that doesn't crash in the first place. If a program crashes and you don't know why and have it automatically start up again won't the same conditions exist as the first time and it will crash again? It sounds like doubling down on a bad bet. Nov 20, 2019 at 4:21

1 Answer 1

0

There are actually many ways to accomplish this goal, and it can go from trivial home-grown (eg, while true; do my_process; done (ps: don't do that)) to more complicated patterns (eg involving my_process.pid with init scripts and custom log file rotations)... but before going down that rabbit hole, look at existing solutions that accomplish the same thing. For example: supervisor (see also this tutorial ) or monit, both available via apt install ..., but both just requiring some additional configuration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .