Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-11518][Agent] Support multiple processes #11519

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions inlong-agent/agent-installer/bin/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ function help() {
echo " help: get help from agent installer"
}

function getPid() {
local process_name="installer.Main"
local user=$(whoami)
local pid=$(ps -u $user -f | grep 'java' | grep "$process_name" | grep -v grep | awk '{print $2}')

if [ -z "$pid" ]; then
echo "No matching process found."
return 1
fi

echo "$pid"
return 0
}

function running() {
process=$("$JPS" -l| grep "installer.Main" | grep -v grep)
if [ "${process}" = "" ]; then
return 1;
else
return 0;
fi
pid=$(getPid)
if [ $? -eq 0 ]; then
return 0
else
return 1
fi
}

# start installer
Expand All @@ -56,7 +70,7 @@ function stop_installer() {
exit 1
fi
count=0
pid=$("$JPS" -l| grep "installer.Main"| grep -v grep | awk '{print $1}')
pid=$(getPid)
while running;
do
(( count++ ))
Expand Down
33 changes: 24 additions & 9 deletions inlong-agent/bin/agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,28 @@ function help() {
echo " help: get help from inlong agent"
}


function getPid() {
local process_name="inlong-agent"
local user=$(whoami)
local pid=$(ps -u $user -f | grep 'java' | grep "$process_name" | grep -v grep | awk '{print $2}')

if [ -z "$pid" ]; then
echo "No matching process found."
return 1
fi

echo "$pid"
return 0
}

function running() {
process=$("$JPS" | grep "AgentMain" | grep -v grep)
if [ "${process}" = "" ]; then
return 1;
else
return 0;
fi
pid=$(getPid)
if [ $? -eq 0 ]; then
return 0
else
return 1
fi
}

# start agent
Expand All @@ -53,9 +68,9 @@ function start_agent() {
exit 1
fi
if [ "$ENABLE_OBSERVABILITY" = "true" ]; then
nohup ${JAVA} ${AGENT_ARGS} -javaagent:${OTEL_AGENT} org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
nohup ${JAVA} ${AGENT_ARGS} ${arg_uniq} -javaagent:${OTEL_AGENT} org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
else
nohup ${JAVA} ${AGENT_ARGS} org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
nohup ${JAVA} ${AGENT_ARGS} ${arg_uniq} org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
fi
}

Expand All @@ -66,7 +81,7 @@ function stop_agent() {
exit 1
fi
count=0
pid=$("$JPS" | grep "AgentMain" | grep -v grep | awk '{print $1}')
pid=$(getPid)
while running;
do
(( count++ ))
Expand Down
Loading