Skip to content

Commit

Permalink
#20 fix agent scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
龚德伟 committed Nov 26, 2019
1 parent ba8a025 commit a8fc518
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion assets/agent/bin/start-agent-as-service.bat
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if %srv_interact%==0 set flare_args=%flare_args% --no-interact
if %ignoreTools%==1 set flare_args=%flare_args% --ignore-tools
if %flare_service%==1 (
REM run xxx.bat
start /wait %basedir%\start-trace-agent.bat %pid% %interval% %flare_args%
start /wait %basedir%\start-agent.bat %pid% %interval% %flare_args%
exit 0

REM DEBUG run args
Expand Down
21 changes: 12 additions & 9 deletions assets/agent/bin/start-agent-as-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
PROJECT_PATH="$(cd "$(dirname $0)/.."; pwd -P )"

USER_ACCOUNT="$1"
TARGET_PID="$2"

if [[ "$USER_ACCOUNT" == "" ]];then
echo "usage: $0 <username> <pid>"
echo "required username"
echo "usage: $0 <username> <pid> [options]"
exit 1
fi
shift;

ACTION_SCRIPT="start-trace-agent.sh"

if [[ "$TARGET_PID" == "" ]];then
echo "TARGET_PID is required"
TARGET_PID="$1"
if [[ "$TARGET_PID" -eq "" ]];then
echo "required target java pid"
echo "usage: $0 <username> <pid> [options]"
exit 1
fi
shift;

ACTION_SCRIPT="start-agent.sh"

#may not have permission to create log dir
#/usr/bin/su - $USER_ACCOUNT -s /bin/sh -c "$PROJECT_PATH/bin/$ACTION_SCRIPT $TARGET_PID > $PROJECT_PATH/logs/flare_agent_stdout.log 2>&1 & "
/usr/bin/su - $USER_ACCOUNT -s /bin/sh -c "$PROJECT_PATH/bin/$ACTION_SCRIPT $TARGET_PID & "
#/usr/bin/su - $USER_ACCOUNT -s /bin/sh -c "$PROJECT_PATH/bin/$ACTION_SCRIPT $TARGET_PID $@ > $PROJECT_PATH/logs/flare_agent_stdout.log 2>&1 & "
/usr/bin/su - $USER_ACCOUNT -s /bin/sh -c "$PROJECT_PATH/bin/$ACTION_SCRIPT $TARGET_PID $@ & "
2 changes: 1 addition & 1 deletion assets/agent/bin/start-agent.bat
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ goto end


:usage
echo Usage: start-trace-agent.bat ^<pid^> ^[options^]
echo Usage: start-agent.bat ^<pid^> ^[options^]
echo Options:
echo -interval ^<sample interval^> # sample interval(ms), default value is 5
echo -address ^<agent address^> # agent bind address, default value is 0.0.0.0:3333
Expand Down
2 changes: 1 addition & 1 deletion assets/agent/bin/start-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ $JAVA_HOME/bin/java -Xbootclasspath/a:$JAVA_HOME/lib/tools.jar -jar $ATTACHER_PA
goto end

# usage: #
echo "Usage: start-trace-agent.bat <pid> [options]"
echo "Usage: ./start-agent.sh <pid> [options]"
echo "Options:"
echo " -interval <sample interval> # sample interval(ms), default value is 5"
echo " -address <agent address> # agent bind address, default value is 0.0.0.0:3333"
Expand Down
2 changes: 1 addition & 1 deletion assets/agent/bin/stop-agent-as-service.bat
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if %srv_interact%==0 set flare_args=%flare_args% --no-interact
if %ignoreTools%==1 set flare_args=%flare_args% --ignore-tools
if %flare_service%==1 (
REM run xxx.bat
start /wait %basedir%\stop-trace-agent.bat %pid% %flare_args%
start /wait %basedir%\stop-agent.bat %pid% %flare_args%
exit 0

REM DEBUG run args
Expand Down
2 changes: 1 addition & 1 deletion assets/agent/bin/stop-agent-as-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [[ "$USER_ACCOUNT" == "" ]];then
exit 1
fi

ACTION_SCRIPT="stop-trace-agent.sh"
ACTION_SCRIPT="stop-agent.sh"

if [[ "$TARGET_PID" == "" ]];then
echo "TARGET_PID is required"
Expand Down
2 changes: 1 addition & 1 deletion assets/agent/bin/stop-agent.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set AGENT_OPTIONS=trace=off

set TARGET_PID=%1
if "%TARGET_PID%" == "" (
echo "usage: stop-trace-agent.bat <pid>"
echo "usage: stop-agent.bat <pid>"
exit /b 1
)

Expand Down
2 changes: 1 addition & 1 deletion assets/agent/bin/stop-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo "PROJECT_PATH:$PROJECT_PATH"

TARGET_PID="$1"
if [[ "$TARGET_PID" -eq "" ]];then
echo "usage: stop-trace-agent.sh <pid>"
echo "usage: stop-agent.sh <pid>"
exit 1
fi

Expand Down

0 comments on commit a8fc518

Please sign in to comment.