Some basic agent startup

This commit is contained in:
2026-03-30 21:50:04 +08:00
parent fcf7371e9e
commit bdbc29649c
11 changed files with 98 additions and 48 deletions

View File

@@ -1,25 +0,0 @@
#!/sbin/openrc-run
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
name="Bootstrap the Cluster"
description="Runs the ctl init bootstrap sequence"
command="/usr/local/bin/ctl"
command_args="init --env-file /opt/monok8s/config/cluster.env"
LOG_DIR="/var/log/monok8s"
LOG_FILE="$LOG_DIR/bootstrap-cluster.log"
depend() {
need localmount
}
start() {
checkpath --directory "$LOG_DIR"
ebegin "Starting the bootstrap sequence"
start-stop-daemon --start \
--exec "$command" \
-- $command_args >>"$LOG_FILE" 2>&1
eend $?
}

View File

@@ -0,0 +1,58 @@
#!/sbin/openrc-run
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
name="monok8s-control-agent"
description="System Control Agent (OSUpgrade controller)"
supervisor=supervise-daemon
command="/usr/local/bin/ctl"
command_args="agent --env-file /opt/monok8s/config/cluster.env"
command_user="root:root"
pidfile="/run/${RC_SVCNAME}.pid"
output_log="/var/log/monok8s/agent.log"
error_log="/var/log/monok8s/agent.log"
retry="TERM/10/KILL/5"
depend() {
need localmount
after net
}
start_pre() {
checkpath --directory /run
checkpath --directory /var/log/monok8s
if [ ! -f /opt/monok8s/config/cluster.env ]; then
eerror "Missing env file: /opt/monok8s/config/cluster.env"
return 1
fi
}
start() {
ebegin "Starting monok8s control agent"
supervise-daemon "$RC_SVCNAME" \
--start \
--pidfile "$pidfile" \
--stdout "$output_log" \
--stderr "$error_log" \
--respawn \
--respawn-delay 5 \
--respawn-max 0 \
-- \
$command $command_args
eend $?
}
stop() {
ebegin "Stopping monok8s control agent"
supervise-daemon "$RC_SVCNAME" \
--stop \
--pidfile "$pidfile"
eend $?
}

View File

@@ -0,0 +1,4 @@
#!/bin/sh
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
/usr/local/bin/ctl init --env-file /opt/monok8s/config/cluster.env >>/var/log/monok8s/bootstrap.log 2>&1 &