From 9c14e8bc2360c0098a23486ea71fc5c99e2fd64e Mon Sep 17 00:00:00 2001 From: tangpeng Date: Tue, 21 Feb 2017 16:42:42 +0800 Subject: Add holmes-engine-d-standalone module Change-Id: I92203b32eac0888ba6df0328a6bc0a918909e3b3 Issue-Id:HOLMES-45 Signed-off-by: tangpeng --- engine-d-standalone/pom.xml | 168 +++++++++++++++++++++ .../src/main/assembly/bin/find_kill_process.bat | 24 +++ .../src/main/assembly/bin/initDB.bat | 34 +++++ .../src/main/assembly/bin/initDB.sh | 34 +++++ engine-d-standalone/src/main/assembly/bin/run.bat | 41 +++++ engine-d-standalone/src/main/assembly/bin/run.sh | 35 +++++ engine-d-standalone/src/main/assembly/bin/stop.bat | 34 +++++ engine-d-standalone/src/main/assembly/bin/stop.sh | 44 ++++++ .../src/main/assembly/conf/engine-d.yml | 72 +++++++++ .../mysql/openo-holmes_engine_d-createobj.sql | 17 +++ pom.xml | 8 + 11 files changed, 511 insertions(+) create mode 100644 engine-d-standalone/pom.xml create mode 100644 engine-d-standalone/src/main/assembly/bin/find_kill_process.bat create mode 100644 engine-d-standalone/src/main/assembly/bin/initDB.bat create mode 100644 engine-d-standalone/src/main/assembly/bin/initDB.sh create mode 100644 engine-d-standalone/src/main/assembly/bin/run.bat create mode 100644 engine-d-standalone/src/main/assembly/bin/run.sh create mode 100644 engine-d-standalone/src/main/assembly/bin/stop.bat create mode 100644 engine-d-standalone/src/main/assembly/bin/stop.sh create mode 100644 engine-d-standalone/src/main/assembly/conf/engine-d.yml create mode 100644 engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql diff --git a/engine-d-standalone/pom.xml b/engine-d-standalone/pom.xml new file mode 100644 index 0000000..b6b14e1 --- /dev/null +++ b/engine-d-standalone/pom.xml @@ -0,0 +1,168 @@ + + + + + org.openo.holmes.engine-management + holmes-engine-parent + 1.1.0-SNAPSHOT + + + holmes-engine-d-standalone + 4.0.0 + holmes-engine/holmes-engine-d-standalone + pom + + + + + maven-resources-plugin + + + copy-resources-${linux64id} + process-resources + + copy-resources + + + ${linux64outputdir} + + + src/main/assembly/ + false + + **/* + + + **/*.bat + + + + true + + + + copy-resources-${win64id} + process-resources + + copy-resources + + + ${win64outputdir} + + + src/main/assembly/ + false + + **/* + + + **/*.sh + + + + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-jar-${linux64id} + + copy + + prepare-package + + + + org.openo.holmes.engine-management + holmes-engine-d + jar + true + ${linux64outputdir} + holmes-engine-d.jar + + + + + + copy-jar-${win64id} + + copy + + prepare-package + + + + org.openo.holmes.engine-management + holmes-engine-d + jar + true + ${win64outputdir} + holmes-engine-d.jar + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + distribution + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.openo.holmes.engine-management + holmes-engine-d + ${project.version} + + + diff --git a/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat b/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat new file mode 100644 index 0000000..6c61d50 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/find_kill_process.bat @@ -0,0 +1,24 @@ +@REM +@REM Copyright 2017 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +echo %1 | findstr %2 >NUL +echo ERRORLEVEL=%ERRORLEVEL% +IF ERRORLEVEL 1 goto findend +for /f "tokens=1" %%a in (%1) do ( + echo kill %1 + taskkill /F /pid %%a +) +:findend \ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/initDB.bat b/engine-d-standalone/src/main/assembly/bin/initDB.bat new file mode 100644 index 0000000..29a795c --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/initDB.bat @@ -0,0 +1,34 @@ +@REM +@REM Copyright 2017 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +set HOME=%~dp0 +set user=%1 +set password=%2 +set port=%3 +set host=%4 +echo start init holmes engine-d db +echo HOME=%HOME% +set main_path=%HOME%..\ +cd /d %main_path% +mysql -u%user% -p%password% -P%port% -h%host% < %main_path%\dbscripts\mysql\openo-holmes_engine_d-createobj.sql +set "err=%errorlevel%" +if "%err%"=="0" ( + echo init engine-d db success + ) else ( + echo failed init engine-d db + pause + ) \ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/initDB.sh b/engine-d-standalone/src/main/assembly/bin/initDB.sh new file mode 100644 index 0000000..7f16c2a --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/initDB.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +user=$1 +password=$2 +port=$3 +host=$4 +echo "start init holmes engine-d db" +main_path=$HOME/../ +mysql -u$user -p$password -P$port -h$host <$main_path/dbscripts/mysql/openo-holmes_engine_d-createobj.sql +sql_result=$? +if [ $sql_result != 0 ] ; then + echo "failed to init engine-d database!" + exit 1 +fi +echo "init engine-d success!" +exit 0 + diff --git a/engine-d-standalone/src/main/assembly/bin/run.bat b/engine-d-standalone/src/main/assembly/bin/run.bat new file mode 100644 index 0000000..89151e8 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/run.bat @@ -0,0 +1,41 @@ +@REM +@REM Copyright 2017 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +title holmes-engine-d-service + +set RUNHOME=%~dp0 +echo ### RUNHOME: %RUNHOME% +echo ### Starting engine-d-service +set main_path=%RUNHOME%..\ +cd /d %main_path% +set JAVA="%JAVA_HOME%\bin\java.exe" +set port=8312 +set jvm_opts=-Xms50m -Xmx128m +rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n +set class_path=%main_path%;%main_path%holmes-engine-d.jar +echo ### jvm_opts: %jvm_opts% +echo ### class_path: %class_path% + +%JAVA% -classpath %class_path% %jvm_opts% org.openo.holmes.engine.EngineDActiveApp server %main_path%conf/engine-d.yml + +IF ERRORLEVEL 1 goto showerror +exit +:showerror +echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check! +echo After checking, press any key to close +pause +exit \ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/run.sh b/engine-d-standalone/src/main/assembly/bin/run.sh new file mode 100644 index 0000000..4a93b50 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/run.sh @@ -0,0 +1,35 @@ +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +RUNHOME=`cd $DIRNAME/; pwd` +echo @RUNHOME@ $RUNHOME + +echo @JAVA_HOME@ $JAVA_HOME +JAVA="$JAVA_HOME/bin/java" +echo @JAVA@ $JAVA +main_path=$RUNHOME/../ +cd $main_path +JAVA_OPTS="-Xms50m -Xmx128m" +port=8312 +#JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n" +echo @JAVA_OPTS@ $JAVA_OPTS + +class_path="$main_path/:$main_path/holmes-engine-d.jar" +echo @class_path@ $class_path + +"$JAVA" $JAVA_OPTS -classpath "$class_path" org.openo.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml" + diff --git a/engine-d-standalone/src/main/assembly/bin/stop.bat b/engine-d-standalone/src/main/assembly/bin/stop.bat new file mode 100644 index 0000000..22280e7 --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/stop.bat @@ -0,0 +1,34 @@ +@REM +@REM Copyright 2017 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +title stopping engine-d-service + +set HOME=%~dp0 +set Main_Class="org.openo.holmes.engine.EngineDActiveApp" + +echo ================== engine-d-service info ============================================= +echo HOME=$HOME +echo Main_Class=%Main_Class% +echo =============================================================================== + +echo ### Stopping engine-d-service +cd /d %HOME% + +for /f "delims=" %%i in ('"%JAVA_HOME%\bin\jcmd"') do ( + call find_kill_process "%%i" %Main_Class% +) +exit \ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/bin/stop.sh b/engine-d-standalone/src/main/assembly/bin/stop.sh new file mode 100644 index 0000000..8f81bda --- /dev/null +++ b/engine-d-standalone/src/main/assembly/bin/stop.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +Main_Class="org.openo.holmes.engine.EngineDActiveApp" + +echo ================== engine-d-service info ============================================= +echo HOME=$HOME +echo Main_Class=$Main_Class +echo =============================================================================== +cd $HOME; pwd + +echo @WORK_DIR@ $HOME + +function save_service_pid(){ + service_pid=`ps -ef | grep $Main_Class | grep -v grep | awk '{print $2}'` + echo @service_pid@ $service_pid +} + +function kill_service_process(){ + ps -p $service_pid + if [ $? == 0 ]; then + kill -9 $service_pid + fi +} + +save_service_pid; +echo @C_CMD@ kill -9 $service_pid +kill_service_process; \ No newline at end of file diff --git a/engine-d-standalone/src/main/assembly/conf/engine-d.yml b/engine-d-standalone/src/main/assembly/conf/engine-d.yml new file mode 100644 index 0000000..247ac4b --- /dev/null +++ b/engine-d-standalone/src/main/assembly/conf/engine-d.yml @@ -0,0 +1,72 @@ +# +# Copyright 2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +server: + type: simple + rootPath: '/api/holmes-engine/v1/*' + applicationContextPath: / + adminContextPath: /admin + connector: + type: http + port: 12003 + + +# Logging settings. +logging: + + # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. + level: INFO + + # Logger-specific levels. + loggers: + + # Sets the level for 'com.example.app' to DEBUG. + com.example: DEBUG + + appenders: + - type: console + threshold: INFO + timeZone: UTC + logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n" + - type: file + threshold: INFO + logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n" + currentLogFilename: ../logs/holmes-engine-d.log + archivedLogFilenamePattern: ../logs/zip/holmes-engine-d-%d{yyyy-MM-dd}.log.gz + archivedFileCount: 7 + + +database: + driverClass: com.mysql.jdbc.Driver + user: root + password: root321 +# url: jdbc:mysql://${db_ip}:${db_port}/mysql?useUnicode=relationtesttrue&characterEncoding=UTF8 + url: jdbc:mysql://10.74.156.206:3306/mysql?useUnicode=true&characterEncoding=UTF8 + properties: + charSet: UTF-8 + maxWaitForConnection: 1s + validationQuery: "/* MyService Health Check */ SELECT 1" + minSize: 8 + maxSize: 100 + checkConnectionWhileIdle: false + evictionInterval: 10s + minIdleTime: 1s + +mqConfig: + brokerIp: 127.0.0.1 + brokerPort: 61616 + mqServiceName: activemq + mqServiceVersion: v1 + diff --git a/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql b/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql new file mode 100644 index 0000000..4f5294a --- /dev/null +++ b/engine-d-standalone/src/main/assembly/dbscripts/mysql/openo-holmes_engine_d-createobj.sql @@ -0,0 +1,17 @@ +-- +-- Copyright 2017 ZTE Corporation. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + + diff --git a/pom.xml b/pom.xml index 6e90aa4..89c3963 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ holmes-engine-parent engine-d + engine-d-standalone UTF-8 @@ -54,6 +55,13 @@ 5.0 1.6.1 2.2.1 + + openo-holmes-engine-d + linux64 + win64 + target/assembly/${linux64id} + target/assembly/${win64id} + target/version -- cgit 1.2.3-korg