Skip to content

Commit 12d9207

Browse files
authored
[Summer of code] Add sh conf for controller
1 parent addd307 commit 12d9207

File tree

5 files changed

+184
-2
lines changed

5 files changed

+184
-2
lines changed

distribution/bin/mqcontroller

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
if [ -z "$ROCKETMQ_HOME" ] ; then
19+
## resolve links - $0 may be a link to maven's home
20+
PRG="$0"
21+
22+
# need this for relative symlinks
23+
while [ -h "$PRG" ] ; do
24+
ls=`ls -ld "$PRG"`
25+
link=`expr "$ls" : '.*-> \(.*\)$'`
26+
if expr "$link" : '/.*' > /dev/null; then
27+
PRG="$link"
28+
else
29+
PRG="`dirname "$PRG"`/$link"
30+
fi
31+
done
32+
33+
saveddir=`pwd`
34+
35+
ROCKETMQ_HOME=`dirname "$PRG"`/..
36+
37+
# make it fully qualified
38+
ROCKETMQ_HOME=`cd "$ROCKETMQ_HOME" && pwd`
39+
40+
cd "$saveddir"
41+
fi
42+
43+
export ROCKETMQ_HOME
44+
45+
sh ${ROCKETMQ_HOME}/bin/runserver.sh org.apache.rocketmq.controller.ControllerStartup $@

distribution/bin/mqcontroller.cmd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@echo off
2+
rem Licensed to the Apache Software Foundation (ASF) under one or more
3+
rem contributor license agreements. See the NOTICE file distributed with
4+
rem this work for additional information regarding copyright ownership.
5+
rem The ASF licenses this file to You under the Apache License, Version 2.0
6+
rem (the "License"); you may not use this file except in compliance with
7+
rem the License. You may obtain a copy of the License at
8+
rem
9+
rem http://www.apache.org/licenses/LICENSE-2.0
10+
rem
11+
rem Unless required by applicable law or agreed to in writing, software
12+
rem distributed under the License is distributed on an "AS IS" BASIS,
13+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
rem See the License for the specific language governing permissions and
15+
rem limitations under the License.
16+
17+
if not exist "%ROCKETMQ_HOME%\bin\runserver.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
18+
19+
call "%ROCKETMQ_HOME%\bin\runserver.cmd" org.apache.rocketmq.controller.ControllerStartup %*
20+
21+
IF %ERRORLEVEL% EQU 0 (
22+
ECHO "Controller starts OK"
23+
)

distribution/bin/mqshutdown

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ case $1 in
5858

5959
echo "Send shutdown request to mqnamesrv(${pid}) OK"
6060
;;
61+
controller)
62+
63+
pid=`ps ax | grep -i 'org.apache.rocketmq.controller.ControllerStartup' |grep java | grep -v grep | awk '{print $1}'`
64+
if [ -z "$pid" ] ; then
65+
echo "No mqcontroller running."
66+
exit -1;
67+
fi
68+
69+
echo "The mqcontroller(${pid}) is running..."
70+
71+
kill ${pid}
72+
73+
echo "Send shutdown request to mqcontroller(${pid}) OK"
74+
;;
6175
*)
62-
echo "Useage: mqshutdown broker | namesrv"
76+
echo "Useage: mqshutdown broker | namesrv | controller"
6377
esac

distribution/bin/mqshutdown.cmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ if /I "%1" == "broker" (
2929

3030
for /f "tokens=1" %%i in ('jps -m ^| find "NamesrvStartup"') do ( taskkill /F /PID %%i )
3131

32+
echo Done!
33+
) else if /I "%1" == "controller" (
34+
echo killing controller server
35+
36+
for /f "tokens=1" %%i in ('jps -m ^| find "ControllerStartup"') do ( taskkill /F /PID %%i )
37+
3238
echo Done!
3339
) else (
34-
echo Unknown role to kill, please specify broker or namesrv
40+
echo Unknown role to kill, please specify broker or namesrv or controller
3541
)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<configuration>
20+
<appender name="DefaultAppender"
21+
class="ch.qos.logback.core.rolling.RollingFileAppender">
22+
<file>${user.home}/logs/rocketmqlogs/controller_default.log</file>
23+
<append>true</append>
24+
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
25+
<fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/controller_default.%i.log.gz</fileNamePattern>
26+
<minIndex>1</minIndex>
27+
<maxIndex>5</maxIndex>
28+
</rollingPolicy>
29+
<triggeringPolicy
30+
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
31+
<maxFileSize>100MB</maxFileSize>
32+
</triggeringPolicy>
33+
<encoder>
34+
<pattern>%d{yyy-MM-dd HH:mm:ss,GMT+8} %p %t - %m%n</pattern>
35+
<charset class="java.nio.charset.Charset">UTF-8</charset>
36+
</encoder>
37+
</appender>
38+
39+
<appender name="RocketmqControllerAppender_inner"
40+
class="ch.qos.logback.core.rolling.RollingFileAppender">
41+
<file>${user.home}/logs/rocketmqlogs/controller.log</file>
42+
<append>true</append>
43+
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
44+
<fileNamePattern>${user.home}/logs/rocketmqlogs/otherdays/controller.%i.log.gz</fileNamePattern>
45+
<minIndex>1</minIndex>
46+
<maxIndex>5</maxIndex>
47+
</rollingPolicy>
48+
<triggeringPolicy
49+
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
50+
<maxFileSize>100MB</maxFileSize>
51+
</triggeringPolicy>
52+
<encoder>
53+
<pattern>%d{yyy-MM-dd HH:mm:ss,GMT+8} %p %t - %m%n</pattern>
54+
<charset class="java.nio.charset.Charset">UTF-8</charset>
55+
</encoder>
56+
</appender>
57+
<appender name="RocketmqControllerAppender" class="ch.qos.logback.classic.AsyncAppender">
58+
<appender-ref ref="RocketmqControllerAppender_inner"/>
59+
<discardingThreshold>0</discardingThreshold>
60+
</appender>
61+
62+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
63+
<append>true</append>
64+
<encoder>
65+
<pattern>%d{yyy-MM-dd HH\:mm\:ss,SSS} %p %t - %m%n</pattern>
66+
<charset class="java.nio.charset.Charset">UTF-8</charset>
67+
</encoder>
68+
</appender>
69+
70+
<logger name="RocketmqController" additivity="false">
71+
<level value="INFO"/>
72+
<appender-ref ref="RocketmqControllerAppender"/>
73+
</logger>
74+
75+
<logger name="RocketmqCommon" additivity="false">
76+
<level value="INFO"/>
77+
<appender-ref ref="RocketmqControllerAppender"/>
78+
</logger>
79+
80+
<logger name="RocketmqRemoting" additivity="false">
81+
<level value="INFO"/>
82+
<appender-ref ref="RocketmqControllerAppender"/>
83+
</logger>
84+
85+
<logger name="RocketmqControllerConsole" additivity="false">
86+
<level value="INFO"/>
87+
<appender-ref ref="STDOUT"/>
88+
</logger>
89+
90+
<root>
91+
<level value="INFO"/>
92+
<appender-ref ref="DefaultAppender"/>
93+
</root>
94+
</configuration>

0 commit comments

Comments
 (0)