From 23ade91cd5c18af93a6fc529f003b124fb6d0a6a Mon Sep 17 00:00:00 2001 From: YuanHu Date: Tue, 13 Feb 2018 11:22:10 +0800 Subject: Setup and Publish Backend Service. Setup backend service with dropwizard application framework. Integrate backend with frontend to one micro-service. Issue-ID: SDC-408 Change-Id: Ia6949302ee7c7ad6a4ce31e263f6a38183adfee3 Signed-off-by: YuanHu --- distribution/pom.xml | 241 ++++++++++----------- distribution/src/main/assembly/Dockerfile | 26 --- .../src/main/assembly/bin/find_kill_process.bat | 20 ++ distribution/src/main/assembly/bin/run.bat | 37 ++++ distribution/src/main/assembly/bin/stop.bat | 30 +++ distribution/src/main/assembly/bin/stop.sh | 39 ++++ .../src/main/assembly/conf/workflow-designer.yml | 50 +++++ distribution/src/main/assembly/shutdown.bat | 24 -- distribution/src/main/assembly/shutdown.sh | 27 --- distribution/src/main/assembly/startup.bat | 26 --- distribution/src/main/assembly/startup.sh | 28 --- distribution/src/main/docker/Dockerfile | 26 +++ 12 files changed, 319 insertions(+), 255 deletions(-) delete mode 100644 distribution/src/main/assembly/Dockerfile create mode 100644 distribution/src/main/assembly/bin/find_kill_process.bat create mode 100644 distribution/src/main/assembly/bin/run.bat create mode 100644 distribution/src/main/assembly/bin/stop.bat create mode 100644 distribution/src/main/assembly/bin/stop.sh create mode 100644 distribution/src/main/assembly/conf/workflow-designer.yml delete mode 100644 distribution/src/main/assembly/shutdown.bat delete mode 100644 distribution/src/main/assembly/shutdown.sh delete mode 100644 distribution/src/main/assembly/startup.bat delete mode 100644 distribution/src/main/assembly/startup.sh create mode 100644 distribution/src/main/docker/Dockerfile (limited to 'distribution') diff --git a/distribution/pom.xml b/distribution/pom.xml index cf85df22..6b15fd2f 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -16,7 +16,7 @@ org.onap.sdc.sdc-workflow-designer sdc-workflow-designer - 1.0.0 + 1.1.0-SNAPSHOT 4.0.0 @@ -26,53 +26,60 @@ pom - sdc-workflow-designer + sdc-workflow-designer + sdc-workflow-designer.jar + src/main/assembly + src/main/docker linux64 win64 - target/assembly/${linux64id} - target/assembly/${win64id} + target/assembly/linux64 + target/assembly/win64 target/version + target - - - - org.apache.maven.plugins - maven-dependency-plugin + + + + + maven-assembly-plugin + + + + org.onap.sdc.workflowdesigner.WorkflowDesignerApp + + + + jar-with-dependencies + + - unpack-tomcat-to-temporary-dir - generate-resources + assembly-ui-and-backend + process-sources - unpack + single - - - - org.apache.tomcat - tomcat - zip - target/tomcat - - - + + maven-resources-plugin - copy-resources-${linux64id} + copy-assembly-and-jar-${linux64id} process-resources copy-resources ${linux64outputdir} + true - src/main/assembly/ + ${src.assembly} false **/* @@ -81,64 +88,35 @@ **/*.bat - - true - - - - - copy-tomcat-resources-${linux64id} - process-resources - - copy-resources - - - ${linux64outputdir}/tomcat - - ${basedir}/target/tomcat/apache-tomcat-${tomcat.version} - - **/* - - - **/*.bat - - - - - - - - copy-workflow-designer-resources-${linux64id} - process-resources - - copy-resources - - - ${linux64outputdir}/tomcat/webapps/ROOT - - - ${basedir}/../sdc-workflow-designer-ui/dist + ${target.dir} + false - **/* + *.jar - true - + + + + + + maven-resources-plugin + - copy-resources-${win64id} + copy-assembly-and-jar-${win64id} process-resources copy-resources ${win64outputdir} + true - src/main/assembly/ + ${src.assembly} false **/* @@ -147,76 +125,50 @@ **/*.sh - - true - - - - - copy-tomcat-resources-${win64id} - process-resources - - copy-resources - - - ${win64outputdir}/tomcat - - ${basedir}/target/tomcat/apache-tomcat-${tomcat.version} + ${target.dir} + false - **/* + *.jar - - **/*.sh - - + + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + - copy-workflow-designer-resources-${win64id} + rename-jar-name-${linux64id} process-resources - copy-resources + rename - ${win64outputdir}/tomcat/webapps/ROOT - - - ${basedir}/../sdc-workflow-designer-ui/dist - - **/* - - - - true + ${linux64outputdir}/${project.name}-${project.version}-jar-with-dependencies.jar + ${linux64outputdir}/${project.jar} - - - copy-dockerfile + + rename-jar-name-${win64id} process-resources - copy-resources + rename - ${version.output} - - - src/main/assembly/ - false - - Dockerfile - - - - true + ${win64outputdir}/${project.name}-${project.version}-jar-with-dependencies.jar + ${win64outputdir}/${project.jar} - + + org.apache.maven.plugins maven-antrun-plugin @@ -229,28 +181,55 @@ - - + + - + - - - + + + - + + + + + maven-resources-plugin + + + copy-dockerfile + package + + copy-resources + + + ${version.output} + + + ${src.docker} + false + + Dockerfile + + + + true + + + + - - + + docker @@ -298,5 +277,19 @@ - + + + + org.onap.sdc.sdc-workflow-designer + sdc-workflow-designer-server + ${project.version} + + + + org.onap.sdc.sdc-workflow-designer + sdc-workflow-designer-ui + ${project.version} + + + diff --git a/distribution/src/main/assembly/Dockerfile b/distribution/src/main/assembly/Dockerfile deleted file mode 100644 index eaf0da22..00000000 --- a/distribution/src/main/assembly/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:16.04 - -MAINTAINER "Lv Bo" - -EXPOSE 8080 - -#install openjdk-1.8 -#RUN sed -i 's#http://archive.ubuntu.com#http://mirrors.163.com#g' /etc/apt/sources.list -RUN apt-get update -RUN apt-get install -y openjdk-8-jdk - -#configure the JDK -RUN sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security -ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 -ENV PATH $PATH:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin -ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib -ENV JRE_HOME ${JAVA_HOME}/jre - -#add workflow designer related resources to the docker image -RUN mkdir /home/sdc-workflow-designer -WORKDIR /home/sdc-workflow-designer -ADD sdc-workflow-designer-*-linux64.tar.gz /home/sdc-workflow-designer/ -RUN chmod 755 /home/sdc-workflow-designer/*.sh - -ENTRYPOINT /home/sdc-workflow-designer/startup.sh - diff --git a/distribution/src/main/assembly/bin/find_kill_process.bat b/distribution/src/main/assembly/bin/find_kill_process.bat new file mode 100644 index 00000000..6e08993f --- /dev/null +++ b/distribution/src/main/assembly/bin/find_kill_process.bat @@ -0,0 +1,20 @@ +@REM +@REM Copyright (c) 2017 ZTE Corporation. +@REM All rights reserved. This program and the accompanying materials +@REM are made available under the terms of the Eclipse Public License v1.0 +@REM and the Apache License 2.0 which both accompany this distribution, +@REM and are available at http://www.eclipse.org/legal/epl-v10.html +@REM and http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Contributors: +@REM ZTE - initial API and implementation and/or initial documentation +@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/distribution/src/main/assembly/bin/run.bat b/distribution/src/main/assembly/bin/run.bat new file mode 100644 index 00000000..9ef96478 --- /dev/null +++ b/distribution/src/main/assembly/bin/run.bat @@ -0,0 +1,37 @@ +@REM +@REM Copyright (c) 2017 ZTE Corporation. +@REM All rights reserved. This program and the accompanying materials +@REM are made available under the terms of the Eclipse Public License v1.0 +@REM and the Apache License 2.0 which both accompany this distribution, +@REM and are available at http://www.eclipse.org/legal/epl-v10.html +@REM and http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Contributors: +@REM ZTE - initial API and implementation and/or initial documentation +@REM + +@echo off +title sdc-workflow-designer + +set RUNHOME=%~dp0 +echo ### RUNHOME: %RUNHOME% +echo ### Starting sdc-workflow-designer +set main_path=%RUNHOME%..\ +cd /d %main_path% +set JAVA="%JAVA_HOME%\bin\java.exe" +set port=12345 +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=y +set class_path=%main_path%;%main_path%sdc-workflow-designer.jar +echo ### jvm_opts: %jvm_opts% +echo ### class_path: %class_path% + +%JAVA% -classpath %class_path% %jvm_opts% org.onap.sdc.workflowdesigner.WorkflowDesignerApp server %main_path%conf/workflow-designer.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/distribution/src/main/assembly/bin/stop.bat b/distribution/src/main/assembly/bin/stop.bat new file mode 100644 index 00000000..4407a449 --- /dev/null +++ b/distribution/src/main/assembly/bin/stop.bat @@ -0,0 +1,30 @@ +@REM +@REM Copyright (c) 2017 ZTE Corporation. +@REM All rights reserved. This program and the accompanying materials +@REM are made available under the terms of the Eclipse Public License v1.0 +@REM and the Apache License 2.0 which both accompany this distribution, +@REM and are available at http://www.eclipse.org/legal/epl-v10.html +@REM and http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Contributors: +@REM ZTE - initial API and implementation and/or initial documentation +@REM + +@echo off +title stopping sdc-workflow-designer + +set HOME=%~dp0 +set Main_Class="org.onap.sdc.workflowdesigner.WorkflowDesignerApp" + +echo ================== sdc-workflow-designer info ============================================= +echo HOME=$HOME +echo Main_Class=%Main_Class% +echo =============================================================================== + +echo ### Stopping sdc-workflow-designer +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/distribution/src/main/assembly/bin/stop.sh b/distribution/src/main/assembly/bin/stop.sh new file mode 100644 index 00000000..3fe6d60d --- /dev/null +++ b/distribution/src/main/assembly/bin/stop.sh @@ -0,0 +1,39 @@ +# +# Copyright (c) 2017 ZTE Corporation. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# and the Apache License 2.0 which both accompany this distribution, +# and are available at http://www.eclipse.org/legal/epl-v10.html +# and http://www.apache.org/licenses/LICENSE-2.0 +# +# Contributors: +# ZTE - initial API and implementation and/or initial documentation +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +Main_Class="org.onap.sdc.workflowdesigner.WorkflowDesignerApp" + +echo ================== sdc-workflow-designer 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/distribution/src/main/assembly/conf/workflow-designer.yml b/distribution/src/main/assembly/conf/workflow-designer.yml new file mode 100644 index 00000000..86f96870 --- /dev/null +++ b/distribution/src/main/assembly/conf/workflow-designer.yml @@ -0,0 +1,50 @@ +# +# Copyright (c) 2017 ZTE Corporation. +# All rights reserved. This program and the accompanying materials +# are made available under the Apache License, Version 2.0 +# and the Eclipse Public License v1.0 which both accompany this distribution, +# and are available at http://www.eclipse.org/legal/epl-v10.html +# and http://www.apache.org/licenses/LICENSE-2.0 +# +# Contributors: +# ZTE - initial API and implementation and/or initial documentation +# + +template: Hello, %s! + +defaultName: ${DW_DEFAULT_NAME:-Stranger} + +# use the simple server factory if you only want to run on a single port +server: + type: simple + rootPath: '/api/workflow-modeler/v1/*' + applicationContextPath: / + adminContextPath: /admin + connector: + type: http + port: 8080 + +# Logging settings. +logging: + + # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. + level: ALL + + # Logger-specific levels. + loggers: + + # Sets the level for 'com.example.app' to DEBUG. + org.onap.sdc.workflowdesigner.WorkflowDesignerApp: INFO + + 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: ./works/logs/wfd.log + archivedLogFilenamePattern: ./works/logs/zip/wfd-%d{yyyy-MM-dd}.log.gz + archivedFileCount: 7 + timeZone: UTC diff --git a/distribution/src/main/assembly/shutdown.bat b/distribution/src/main/assembly/shutdown.bat deleted file mode 100644 index c2178a3d..00000000 --- a/distribution/src/main/assembly/shutdown.bat +++ /dev/null @@ -1,24 +0,0 @@ -@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 catalog - -set RUNHOME=%~dp0 -echo ##RUNHOME %RUNHOME% - -echo ### shutdown blueprint -start /D %RUNHOME%tomcat bin\shutdown.bat diff --git a/distribution/src/main/assembly/shutdown.sh b/distribution/src/main/assembly/shutdown.sh deleted file mode 100644 index d1762c7b..00000000 --- a/distribution/src/main/assembly/shutdown.sh +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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 "### shutdown blueprint"; -cd $RUNHOME -cd ./tomcat -export CATALINA_HOME=$RUNHOME/tomcat -export CATALINA_BASE=$RUNHOME/tomcat -$RUNHOME/tomcat/bin/shutdown.sh & -echo "### shutdown blueprint end"; diff --git a/distribution/src/main/assembly/startup.bat b/distribution/src/main/assembly/startup.bat deleted file mode 100644 index 52bfe3c7..00000000 --- a/distribution/src/main/assembly/startup.bat +++ /dev/null @@ -1,26 +0,0 @@ -@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 catalog - -set RUNHOME=%~dp0 -echo ##RUNHOME %RUNHOME% - -set CATALINA_HOME=%RUNHOME%tomcat -set CATALINA_BASE=%RUNHOME%tomcat -echo ### Starting tomcat -start /D %RUNHOME%tomcat bin\startup.bat diff --git a/distribution/src/main/assembly/startup.sh b/distribution/src/main/assembly/startup.sh deleted file mode 100644 index 503b1020..00000000 --- a/distribution/src/main/assembly/startup.sh +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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 "### Starting workflow designer"; -cd ./tomcat -if [ ! -d "$RUNHOME/tomcat/logs" ]; then - mkdir $RUNHOME/tomcat/logs -fi -export CATALINA_HOME=$RUNHOME/tomcat -export CATALINA_BASE=$RUNHOME/tomcat -$RUNHOME/tomcat/bin/catalina.sh run diff --git a/distribution/src/main/docker/Dockerfile b/distribution/src/main/docker/Dockerfile new file mode 100644 index 00000000..b1ac0e54 --- /dev/null +++ b/distribution/src/main/docker/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:16.04 + +MAINTAINER "Lv Bo" + +EXPOSE 8080 + +#install openjdk-1.8 +#RUN sed -i 's#http://archive.ubuntu.com#http://mirrors.163.com#g' /etc/apt/sources.list +RUN apt-get update +RUN apt-get install -y openjdk-8-jdk + +#configure the JDK +RUN sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 +ENV PATH $PATH:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin +ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib +ENV JRE_HOME ${JAVA_HOME}/jre + +#add workflow designer related resources to the docker image +RUN mkdir /home/sdc-workflow-designer +WORKDIR /home/sdc-workflow-designer +ADD sdc-workflow-designer-*-linux64.tar.gz /home/sdc-workflow-designer/ +RUN chmod 755 /home/sdc-workflow-designer/*.sh + +ENTRYPOINT /home/sdc-workflow-designer/bin/run.sh + -- cgit 1.2.3-korg