From dfd3e3ddc9ba14c4be9149009cb3c61dcac8466f Mon Sep 17 00:00:00 2001 From: Shon Feder Date: Fri, 17 May 2024 21:30:56 -0400 Subject: [PATCH 1/2] Run the worker process via `daemon` Closes tarides/infrastructure#308 --- roles/ocluster/templates/worker | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/ocluster/templates/worker b/roles/ocluster/templates/worker index 3ea7536..a9f9761 100644 --- a/roles/ocluster/templates/worker +++ b/roles/ocluster/templates/worker @@ -7,13 +7,22 @@ . /etc/rc.subr name=worker +title=ocluster_worker # Title of the process +# The command to invoke the worker process +worker_command="/usr/local/bin/${name} --connect /etc/ocluster/pool.cap --name {{ inventory_hostname_short }} --state-dir /obuilder/state --obuilder-store zfs:obuilder --obuilder-healthcheck 0 --obuilder-prune-threshold=25 --capacity={{ capacity }} -v" + rcvar=worker_enable PATH=$PATH:/usr/local/bin export PATH -command="/usr/local/bin/${name}" -command_args="--connect /etc/ocluster/pool.cap --name {{ inventory_hostname_short }} --state-dir /obuilder/state --obuilder-store zfs:obuilder --obuilder-healthcheck 0 --obuilder-prune-threshold=25 --capacity={{ capacity }} -v 2>&1 | logger &" +# `daemon` will run the worker process +command="/usr/sbin/daemon" +# --restart : supervise the process and restart it after 1 second if it crashes +# --syslog : direct stdout and stderr to the syslog +# --title : the name to give the process +# See https://man.freebsd.org/cgi/man.cgi?daemon(8) +command_args="--restart --syslog --title ${title} ${worker_command}" load_rc_config $name run_rc_command "$1" From d0890111eaa93a936ce086745a975e3c573b8c11 Mon Sep 17 00:00:00 2001 From: Shon Feder Date: Wed, 22 May 2024 13:54:20 -0400 Subject: [PATCH 2/2] Wait 60 seconds before trying to restart --- roles/ocluster/templates/worker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ocluster/templates/worker b/roles/ocluster/templates/worker index a9f9761..6ad87f1 100644 --- a/roles/ocluster/templates/worker +++ b/roles/ocluster/templates/worker @@ -18,11 +18,11 @@ export PATH # `daemon` will run the worker process command="/usr/sbin/daemon" -# --restart : supervise the process and restart it after 1 second if it crashes +# --restart-delay : Supervise and restart the program after the specified seconds of delay if it has been terminated. # --syslog : direct stdout and stderr to the syslog # --title : the name to give the process # See https://man.freebsd.org/cgi/man.cgi?daemon(8) -command_args="--restart --syslog --title ${title} ${worker_command}" +command_args="--restart-delay 60 --syslog --title ${title} ${worker_command}" load_rc_config $name run_rc_command "$1"