exemONE Agent Installer 작성
This commit is contained in:
26
roles/one_agent/templates/binary_start.sh.j2
Normal file
26
roles/one_agent/templates/binary_start.sh.j2
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_HOST_HOME={{ EXEM_HOME }}/host
|
||||
export RECEIVER_ADDR={{ RECEIVER_ADDR }}:{{ RECEIVER_PORT | default('9010') }}
|
||||
|
||||
|
||||
# START
|
||||
PIDFILE=${EXEM_HOST_HOME}/data/host_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-host-agent)
|
||||
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
echo "exem-host-agent is already running (${PID})"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod 755 ${EXEM_HOST_HOME}/bin/exem-host-agent
|
||||
|
||||
ulimit -n 1024
|
||||
|
||||
${EXEM_HOST_HOME}/bin/exem-host-agent -D
|
||||
39
roles/one_agent/templates/binary_stop.sh.j2
Normal file
39
roles/one_agent/templates/binary_stop.sh.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_HOST_HOME={{ EXEM_HOME }}/host
|
||||
|
||||
|
||||
# STOP
|
||||
PIDFILE=${EXEM_HOST_HOME}/data/host_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
mv ${PIDFILE} ${PIDFILE}.stopped
|
||||
|
||||
# WAITING
|
||||
LIMIT_CNT=10
|
||||
CNT=0
|
||||
while [ ${CNT} -lt ${LIMIT_CNT} ];
|
||||
do
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-host-agent)
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
CNT=$((CNT+1))
|
||||
echo "exem-host-agent is stopping (${PID}) ..."
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${CNT} -ge ${LIMIT_CNT} ]; then
|
||||
echo "Something is wrong. Check exem-host-agent (${PID})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "exem-host-agent is stopped (${PID})"
|
||||
|
||||
else
|
||||
echo "exem-host-agent is not running"
|
||||
fi
|
||||
29
roles/one_agent/templates/exem-host-agent.j2
Normal file
29
roles/one_agent/templates/exem-host-agent.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Startup script for exemONE exem-host-agent
|
||||
# chkconfig: 345 50 50
|
||||
# description: exemONE exem-host-agent
|
||||
# processname: exem-host-agent
|
||||
# directory : EXEM_HOST_HOME={{ EXEM_HOME }}
|
||||
|
||||
source /etc/profile
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
;;
|
||||
stop)
|
||||
echo "Shutting down exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
;;
|
||||
restart)
|
||||
echo "Restarting exem-host-agent: "
|
||||
{{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
{{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service exem-host-agent { start | stop | restart }"
|
||||
exit 1
|
||||
esac
|
||||
exit 0
|
||||
15
roles/one_agent/templates/exem-host-agent.service.j2
Normal file
15
roles/one_agent/templates/exem-host-agent.service.j2
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=exem-host-agent
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile={{ EXEM_HOME }}/host/data/host_agent_pid
|
||||
ExecStart={{ EXEM_HOME }}/host/script/binary_start.sh
|
||||
ExecStartPost=/bin/sleep 1
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
26
roles/one_agent/templates/start.sh.j2
Normal file
26
roles/one_agent/templates/start.sh.j2
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_CONTAINER_HOME={{ EXEM_HOME }}/container
|
||||
export COMMON_RECEIVER_IP={{ RECEIVER_ADDR }}
|
||||
export COMMON_RECEIVER_PORT={{ RECEIVER_CONTAINER_PORT | default('9009') }}
|
||||
export CONTAINER_LOG_LEVEL=info
|
||||
|
||||
|
||||
# START
|
||||
PIDFILE=${EXEM_CONTAINER_HOME}/data/container_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-container-agent)
|
||||
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
echo "exem-container-agent is already running (${PID})"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
chmod 755 ${EXEM_CONTAINER_HOME}/bin/exem-container-agent
|
||||
|
||||
${EXEM_CONTAINER_HOME}/bin/exem-container-agent run
|
||||
39
roles/one_agent/templates/stop.sh.j2
Normal file
39
roles/one_agent/templates/stop.sh.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EXPORT
|
||||
export EXEM_HOME={{ EXEM_HOME }}
|
||||
export EXEM_CONTAINER_HOME={{ EXEM_HOME }}/container
|
||||
|
||||
|
||||
# STOP
|
||||
PIDFILE=${EXEM_CONTAINER_HOME}/data/container_agent_pid
|
||||
|
||||
if [ -f "${PIDFILE}" ]; then
|
||||
PID=$(echo -n | cat ${PIDFILE})
|
||||
mv ${PIDFILE} ${PIDFILE}.stopped
|
||||
|
||||
# WAITING
|
||||
LIMIT_CNT=10
|
||||
CNT=0
|
||||
while [ ${CNT} -lt ${LIMIT_CNT} ];
|
||||
do
|
||||
IS_RUNNING=$(ps -fp "${PID}" | grep -c exem-container-agent)
|
||||
if [ "${IS_RUNNING}" -ne 0 ]; then
|
||||
CNT=$((CNT+1))
|
||||
echo "exem-container-agent is stopping (${PID}) ..."
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${CNT} -ge ${LIMIT_CNT} ]; then
|
||||
echo "Something is wrong. Check exem-container-agent (${PID})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "exem-container-agent is stopped (${PID})"
|
||||
|
||||
else
|
||||
echo "exem-container-agent is not running"
|
||||
fi
|
||||
5
roles/one_agent/templates/systemctl_stop.sh.j2
Normal file
5
roles/one_agent/templates/systemctl_stop.sh.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sudo {{ EXEM_HOME }}/host/script/binary_stop.sh
|
||||
|
||||
sudo systemctl stop exem-host-agent
|
||||
Reference in New Issue
Block a user