process - Maintaining a long-running task on Linux -
my system includes task opens network socket, receives pushed data network, processes it, , writes out disk or pings other machines depending on messages. task intended run forever, , service designed have task running. crashes.
what's best practice keeping task alive? assume it's okay task dead 30 seconds before restart it.
some obvious ideas include having watchdog process checks make sure process still running. watchdog triggered cron. how know if process alive or not? write pidfile? touch heartbeat file? ideal solution wouldn't continuously spin more processes if machine gets bogged down point watchdog running faster heartbeat.
are there standard linux tools this? can imagine solution uses message queue, i'm not sure if that's idea or not.
depending on nature of task wish monitor, 1 method write simple wrapper start task in fork().
the wrapper task can waitpid() on child , restart if terminated.
this depend on modifying source task wish run.
Comments
Post a Comment