From a0295ace2ac4be3cf09c541150c5c563a56d1daa Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sun, 14 Nov 2021 00:33:34 +0100 Subject: [PATCH] Adding init service and fixing the monitor. --- cualsea-server/lib/Cualsea/Server/MonitorController.pm | 2 +- cualsead.init | 8 ++++++++ install.sh | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 cualsead.init diff --git a/cualsea-server/lib/Cualsea/Server/MonitorController.pm b/cualsea-server/lib/Cualsea/Server/MonitorController.pm index fa15766..e8d8f7f 100644 --- a/cualsea-server/lib/Cualsea/Server/MonitorController.pm +++ b/cualsea-server/lib/Cualsea/Server/MonitorController.pm @@ -56,7 +56,7 @@ EOF $started = !system 'ps', '-p', $pid; close $fh; }} - $dbh->do( 'INSERT INTO monitor (date_execution, name, is_up) VALUES (?, ?);', + $dbh->do( 'INSERT INTO monitor (date_execution, name, is_up) VALUES (?, ?, ?);', undef, DateTime->now() . '', $name, $started ); if (!$started) { say "$name stopped"; diff --git a/cualsead.init b/cualsead.init new file mode 100755 index 0000000..63ded04 --- /dev/null +++ b/cualsead.init @@ -0,0 +1,8 @@ +#!/sbin/openrc-run + +description="Cualsead service monitor"; + +pidfile="/run/cualsea/cualsead.pid" +command="cualsead" +command_user="cualsea:cualsea" +command_background="true" diff --git a/install.sh b/install.sh index f3fd45f..e2305ee 100644 --- a/install.sh +++ b/install.sh @@ -12,3 +12,4 @@ cd $current_dir/cualsea-cli && sudo cpan . && cd $current_dir/cualsea-server && sudo cpan . +sudo install -m 755 $current_dir/cualsead.init /etc/init.d/cualsead