diff --git a/food-mq/.classpath b/food-mq/.classpath new file mode 100644 index 0000000..a5d9509 --- /dev/null +++ b/food-mq/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/food-mq/.project b/food-mq/.project new file mode 100644 index 0000000..1f21764 --- /dev/null +++ b/food-mq/.project @@ -0,0 +1,23 @@ + + + food-mq + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/food-mq/.settings/org.eclipse.core.resources.prefs b/food-mq/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..839d647 --- /dev/null +++ b/food-mq/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/food-mq/.settings/org.eclipse.jdt.core.prefs b/food-mq/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2f5cc74 --- /dev/null +++ b/food-mq/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/food-mq/.settings/org.eclipse.m2e.core.prefs b/food-mq/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/food-mq/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/food-mq/assembly.xml b/food-mq/assembly.xml new file mode 100644 index 0000000..a87a265 --- /dev/null +++ b/food-mq/assembly.xml @@ -0,0 +1,49 @@ + + + package + + dir + zip + + true + + + src/main/bin + bin + + + src/main/resources + conf + + application.properties + logback.xml + + + + src/main/conf + conf + + + src/main/logs + logs + + + src/main/lib + lib + + + src/main/temp + temp + + + + + ${project.build.directory}/${artifactId}-${version}.jar + lib + ${artifactId}-${version}.jar + + + \ No newline at end of file diff --git a/food-mq/food-mq.iml b/food-mq/food-mq.iml new file mode 100644 index 0000000..5091df7 --- /dev/null +++ b/food-mq/food-mq.iml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/food-mq/pom.xml b/food-mq/pom.xml new file mode 100644 index 0000000..0264c51 --- /dev/null +++ b/food-mq/pom.xml @@ -0,0 +1,177 @@ + + + 4.0.0 + + com.jwsaas + food-parent + 2.0.0 + + + food-mq + + food-mq + + http://maven.apache.org + + + UTF-8 + UTF-8 + 1.8 + true + 2.0.8.RELEASE + 0.2.0 + + 1.2.0 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springframework.boot + spring-boot-starter-test + + + + com.alibaba.boot + dubbo-spring-boot-starter + ${dubbo-spring-boot-starter.version} + + + org.jboss.netty + netty + + + io.netty + netty + + + + + com.alibaba + dubbo + 2.6.5 + + + org.jboss.netty + netty + + + + + com.alibaba.spring + spring-context-support + 1.0.2 + + + + org.apache.curator + curator-client + 4.0.1 + + + io.netty + netty + + + + + org.apache.curator + curator-framework + 4.0.1 + + + io.netty + netty-handler + + + + com.jwsaas + common-utils + + + + com.jwsaas + food-api + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + ${mqttv3.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + maven-assembly-plugin + + false + + assembly.xml + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + application.properties + logback.xml + + + + + + diff --git a/food-mq/src/main/bin/install.bat b/food-mq/src/main/bin/install.bat new file mode 100644 index 0000000..046a68c --- /dev/null +++ b/food-mq/src/main/bin/install.bat @@ -0,0 +1,140 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM +rem as is. +rem If _WRAPPER_CONF_OVERRIDE is specified then all parameters will be passed. +rem If not set then all parameters starting with the second will be passed. +set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/food-mq/src/main/bin/middleware b/food-mq/src/main/bin/middleware new file mode 100644 index 0000000..ff3ebd0 --- /dev/null +++ b/food-mq/src/main/bin/middleware @@ -0,0 +1,2162 @@ +#! /bin/sh + +# +# Copyright (c) 1999, 2016 Tanuki Software, Ltd. +# http://www.tanukisoftware.com +# All rights reserved. +# +# This software is the proprietary information of Tanuki Software. +# You shall use it only in accordance with the terms of the +# license agreement you entered into with Tanuki Software. +# http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +# +# Java Service Wrapper sh script. Suitable for starting and stopping +# wrapped Java applications on UNIX platforms. +# + +#----------------------------------------------------------------------------- +# These settings can be modified to fit the needs of your application +# Optimized for use with version 3.5.28 of the Wrapper. + +#******************************************************************** +# NOTE - This script has been modified to run the TestWrapper sample +# application and should NOT be used as a base for your own +# applications. All of the documentation assumes that you are +# working from the default source script: +# WRAPPER_HOME/src/bin/sh.script.in +#******************************************************************** + +# IMPORTANT - Please always stop and uninstall an application before making +# any changes to this file. Failure to do so could remove the +# script's ability to control the application. + +# Initialization block for the install_initd and remove_initd scripts used by +# SUSE linux, CentOS and RHEL distributions. +# Note: From CentOS 6, make sure the BEGIN INIT INFO section is before any line +# of code otherwise the service won't be displayed in the Service +# Configuration GUI. +### BEGIN INIT INFO +# Provides: wrapper +# Required-Start: $local_fs $network $syslog +# Should-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Wrapper Sample Application +# Description: Wrapper Sample Application Description +### END INIT INFO + +# Application +APP_NAME="food_mq" +APP_LONG_NAME="food mq application" + +# If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer +# be passed to the wrapper. See documentation for details. +#APP_NAME_PASS_TO_WRAPPER=false + +# Wrapper +WRAPPER_CMD="./wrapper" +WRAPPER_CONF="../conf/wrapper.conf" + +# Priority at which to run the wrapper. See "man nice" for valid priorities. +# nice is only used if a priority is specified. +PRIORITY= + +# Location of the pid file. +PIDDIR="." + +# PIDFILE_CHECK_PID tells the script to double check whether the pid in the pid +# file actually exists and belongs to this application. When not set, only +# check the pid, but not what it is. This is only needed when multiple +# applications need to share the same pid file. +PIDFILE_CHECK_PID=true + +# FIXED_COMMAND tells the script to use a hard coded action rather than +# expecting the first parameter of the command line to be the command. +# By default the command will will be expected to be the first parameter. +#FIXED_COMMAND=console + +# PASS_THROUGH tells the script to pass all arguments through to the JVM +# as is. If FIXED_COMMAND is specified then all arguments will be passed. +# If not set then all arguments starting with the second will be passed. +PASS_THROUGH=true + +# If uncommented, causes the Wrapper to be shutdown using an anchor file. +# When launched with the 'start' command, it will also ignore all INT and +# TERM signals. +#IGNORE_SIGNALS=true + +# Wrapper will start the JVM asynchronously. Your application may have some +# initialization tasks and it may be desirable to wait a few seconds +# before returning. For example, to delay the invocation of following +# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will +# cause the start command to delay for the indicated period of time +# (in seconds). +# +WAIT_AFTER_STARTUP=0 + +# If set, wait for the wrapper to report that the daemon has started +WAIT_FOR_STARTED_STATUS=true +WAIT_FOR_STARTED_TIMEOUT=120 + +# If set, the status, start_msg and stop_msg commands will print out detailed +# state information on the Wrapper and Java processes. +#DETAIL_STATUS=true + +# If set, the 'pause' and 'resume' commands will be enabled. These make it +# possible to pause the JVM or Java application without completely stopping +# the Wrapper. See the wrapper.pausable and wrapper.pausable.stop_jvm +# properties for more information. +#PAUSABLE=true + +# If specified, the Wrapper will be run as the specified user. +# IMPORTANT - Make sure that the user has the required privileges to write +# the PID file and wrapper.log files. Failure to be able to write the log +# file will cause the Wrapper to exit without any way to write out an error +# message. +# NOTE - This will set the user which is used to run the Wrapper as well as +# the JVM and is not useful in situations where a privileged resource or +# port needs to be allocated prior to the user being changed. +#RUN_AS_USER= + +# Set the full path to the 'su' command (substitute user). +# NOTE - In case 'su' is not in the PATH, you can set the absolute path here, +# for example: +# SU_BIN=/bin/su +# NOTE - For Red Hat, the script will use '/sbin/runuser' if it is present and +# ignore the value of SU_BIN. +SU_BIN=su + +# Set option for 'su'. +# In case the user set in RUN_AS_USER has no bash set, the 'su' command will fail. +# The workaround for GNU/Linux system is to specify which bash to use with +# the '-s' option. +#SU_OPTS="-s /bin/bash" + +# Set the full path to the 'id' command. +# For example: +# ID_BIN=/usr/bin/id +ID_BIN=id + +# By default we show a detailed usage block. Uncomment to show brief usage. +#BRIEF_USAGE=true + +# OS service management tool: flag for using Upstart when installing (rather than init.d rc.d) +USE_UPSTART= + +# OS service management tool: flag for using systemd when installing +USE_SYSTEMD= + +# When installing on Mac OSX platforms, the following domain will be used to +# prefix the plist file name. +PLIST_DOMAIN=org.tanukisoftware.wrapper + +# When installing on Mac OSX platforms, this parameter controls whether the daemon +# is to be kept continuously running or to let demand and conditions control the +# invocation. +MACOSX_KEEP_RUNNING="false" + +# The following two lines are used by the chkconfig command. Change as is +# appropriate for your application. They should remain commented. +# chkconfig: 2345 20 80 +# description: Test Wrapper Sample Application + +# Set run level to use when installing the application to start and stop on +# system startup and shutdown. It is important that the application always +# be uninstalled before making any changes to the run levels. +# It is also possible to specify different run levels based on the individual +# platform. When doing so this script will look for defined run levels in +# the following order: +# 1) "RUN_LEVEL_S_$DIST_OS" or "RUN_LEVEL_K_$DIST_OS", where "$DIST_OS" is +# the value of DIST_OS. "RUN_LEVEL_S_solaris=20" for example. +# 2) RUN_LEVEL_S or RUN_LEVEL_K, to specify specify start or stop run levels. +# 3) RUN_LEVEL, to specify a general run level. +RUN_LEVEL=20 + +# Do not modify anything beyond this point +#----------------------------------------------------------------------------- + +# check if we are running under Cygwin terminal. +# Note: on some OS's (for example Solaris, MacOS), -o is not a valid parameter +# and it shows an error message. We redirect stderr to null so the error message +# doesn't show up. +CYGWIN=`uname -o 2>/dev/null` +if [ "$CYGWIN" = "Cygwin" ] +then + eval echo `gettext 'This script is not compatible with Cygwin. Please use the Wrapper batch files to control the Wrapper.'` + exit 1 +fi + +if [ -n "$FIXED_COMMAND" ] +then + COMMAND="$FIXED_COMMAND" +else + COMMAND="$1" +fi + +# check if there is a parameter "sysd" +SYSD= +if [ $# -gt 1 ] ; then + if [ $2 = "sysd" ] ; then + SYSD=1 + fi +fi + +# default location for the service file +SYSTEMD_SERVICE_FILE="/etc/systemd/system/$APP_NAME.service" + +# Required for HP-UX Startup +if [ `uname -s` = "HP-UX" -o `uname -s` = "HP-UX64" ] ; then + PATH=$PATH:/usr/bin +fi + +# Get the fully qualified path to the script +case $0 in + /*) + SCRIPT="$0" + ;; + *) + PWD=`pwd` + SCRIPT="$PWD/$0" + ;; +esac + +# Resolve the true real path without any sym links. +CHANGED=true +while [ "X$CHANGED" != "X" ] +do + # Change spaces to ":" so the tokens can be parsed. + SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'` + # Get the real path to this script, resolving any symbolic links + TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'` + REALPATH= + for C in $TOKENS; do + # Change any ":" in the token back to a space. + C=`echo $C | sed -e 's;:; ;g'` + REALPATH="$REALPATH/$C" + # If REALPATH is a sym link, resolve it. Loop for nested links. + while [ -h "$REALPATH" ] ; do + LS="`ls -ld "$REALPATH"`" + LINK="`expr "$LS" : '.*-> \(.*\)$'`" + if expr "$LINK" : '/.*' > /dev/null; then + # LINK is absolute. + REALPATH="$LINK" + else + # LINK is relative. + REALPATH="`dirname "$REALPATH"`""/$LINK" + fi + done + done + + if [ "$REALPATH" = "$SCRIPT" ] + then + CHANGED="" + else + SCRIPT="$REALPATH" + fi +done + +# Get the location of the script. +REALDIR=`dirname "$REALPATH"` +# Normalize the path +REALDIR=`cd "${REALDIR}"; pwd` + +# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if +# the working directory is later changed. +FIRST_CHAR=`echo $PIDDIR | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + PIDDIR=$REALDIR/$PIDDIR +fi +# Same test for WRAPPER_CMD +FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + WRAPPER_CMD=$REALDIR/$WRAPPER_CMD +fi +# Same test for WRAPPER_CONF +FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + WRAPPER_CONF=$REALDIR/$WRAPPER_CONF +fi + +# Process ID +ANCHORFILE="$PIDDIR/$APP_NAME.anchor" +COMMANDFILE="$PIDDIR/$APP_NAME.command" +STATUSFILE="$PIDDIR/$APP_NAME.status" +JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status" +PIDFILE="$PIDDIR/$APP_NAME.pid" +LOCKDIR="/var/lock/subsys" +LOCKFILE="$LOCKDIR/$APP_NAME" +pid="" + +# Resolve the location of the 'ps' command +PS_BIN="/usr/ucb/ps" + if [ ! -x "$PS_BIN" ] + then + PS_BIN="/usr/bin/ps" + if [ ! -x "$PS_BIN" ] + then + PS_BIN="/bin/ps" + if [ ! -x "$PS_BIN" ] + then + eval echo `gettext 'Unable to locate "ps".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi + fi + fi + +TR_BIN="/usr/bin/tr" +if [ ! -x "$TR_BIN" ] +then + TR_BIN="/bin/tr" + if [ ! -x "$TR_BIN" ] + then + eval echo `gettext 'Unable to locate "tr".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi +fi +# Resolve the os +DIST_OS=`uname -s | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` +case "$DIST_OS" in + 'sunos') + DIST_OS="solaris" + ;; + 'hp-ux' | 'hp-ux64') + # HP-UX needs the XPG4 version of ps (for -o args) + DIST_OS="hpux" + UNIX95="" + export UNIX95 + ;; + 'darwin') + DIST_OS="macosx" + ;; + 'unix_sv') + DIST_OS="unixware" + ;; + 'os/390') + DIST_OS="zos" + ;; +esac + +# Compare Versions $1<$2=0, $1==$2=1, $1>$2=2 +compareVersions () { + if [ "$1" = "$2" ] + then + return 1 + else + local i=1 + while true + do + local v1=`echo "$1" | cut -d '.' -f $i` + local v2=`echo "$2" | cut -d '.' -f $i` + if [ "X$v1" = "X" ] + then + if [ "X$v2" = "X" ] + then + return 1 + fi + v1="0" + elif [ "X$v2" = "X" ] + then + v2="0" + fi + if [ $v1 -lt $v2 ] + then + return 0 + elif [ $v1 -gt $v2 ] + then + return 2 + fi + i=`expr $i + 1` + done + fi +} + +# Resolve the architecture +if [ "$DIST_OS" = "macosx" ] +then + OS_VER=`sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\|[0-9]*\.[0-9]*'` + DIST_ARCH="universal" + compareVersions "$OS_VER" "10.5.0" + if [[ $? < 1 ]] + then + DIST_BITS="32" + KEY_KEEP_ALIVE="OnDemand" + else + # Note: "OnDemand" has been deprecated and replaced from Mac OS X 10.5 by "KeepAlive" + KEY_KEEP_ALIVE="KeepAlive" + + if [ "X`/usr/sbin/sysctl -n hw.cpu64bit_capable`" = "X1" ] + then + DIST_BITS="64" + else + DIST_BITS="32" + fi + fi + APP_PLIST_BASE=${PLIST_DOMAIN}.${APP_NAME} + APP_PLIST=${APP_PLIST_BASE}.plist +else + if [ "$DIST_OS" = "linux" ] + then + DIST_ARCH= + else + DIST_ARCH=`uname -p 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` + fi + if [ "X$DIST_ARCH" = "X" ] + then + DIST_ARCH="unknown" + fi + if [ "$DIST_ARCH" = "unknown" ] + then + DIST_ARCH=`uname -m 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` + fi + case "$DIST_ARCH" in + 'athlon' | 'i386' | 'i486' | 'i586' | 'i686') + DIST_ARCH="x86" + if [ "${DIST_OS}" = "solaris" ] ; then + DIST_BITS=`isainfo -b` + else + DIST_BITS="32" + fi + ;; + 'amd64' | 'x86_64') + DIST_ARCH="x86" + DIST_BITS="64" + ;; + 'ia32') + DIST_ARCH="ia" + DIST_BITS="32" + ;; + 'ia64' | 'ia64n' | 'ia64w') + DIST_ARCH="ia" + DIST_BITS="64" + ;; + 'ip27') + DIST_ARCH="mips" + DIST_BITS="32" + ;; + 'power' | 'powerpc' | 'power_pc' | 'ppc64') + if [ "${DIST_ARCH}" = "ppc64" ] ; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + DIST_ARCH="ppc" + if [ "${DIST_OS}" = "aix" ] ; then + if [ `getconf KERNEL_BITMODE` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + fi + ;; + 'pa_risc' | 'pa-risc') + DIST_ARCH="parisc" + if [ `getconf KERNEL_BITS` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + ;; + 'sun4u' | 'sparcv9' | 'sparc') + DIST_ARCH="sparc" + DIST_BITS=`isainfo -b` + ;; + '9000/800' | '9000/785') + DIST_ARCH="parisc" + if [ `getconf KERNEL_BITS` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + ;; + '2064' | '2066' | '2084' | '2086' | '2094' | '2096' | '2097' | '2098' | '2817') + DIST_ARCH="390" + DIST_BITS="64" + ;; + armv*) + if [ -z "`readelf -A /proc/self/exe | grep Tag_ABI_VFP_args`" ] ; then + DIST_ARCH="armel" + DIST_BITS="32" + else + DIST_ARCH="armhf" + DIST_BITS="32" + fi + ;; + esac +fi + +# OSX always places Java in the same location so we can reliably set JAVA_HOME +if [ "$DIST_OS" = "macosx" ] +then + if [ -z "$JAVA_HOME" ]; then + if [ -x /usr/libexec/java_home ]; then + JAVA_HOME=`/usr/libexec/java_home`; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi +fi + +# Test Echo +ECHOTEST=`echo -n "x"` +if [ "$ECHOTEST" = "x" ] +then + ECHOOPT="-n " + ECHOOPTC="" +else + ECHOOPT="" + ECHOOPTC="\c" +fi + + +gettext() { + "$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null + if [ $? != 0 ] ; then + echo "$1" + fi +} + +outputFile() { + if [ -f "$1" ] + then + eval echo `gettext ' $1 Found but not executable.'`; + else + echo " $1" + fi +} + +# Decide on the wrapper binary to use. +# If the bits of the OS could be detected, we will try to look for the +# binary with the correct bits value. If it doesn't exist, fall back +# and look for the 32-bit binary. If that doesn't exist either then +# look for the default. +WRAPPER_TEST_CMD="" +if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" -a -z "$WRAPPER_TEST_CMD" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -f "$WRAPPER_CMD" -a -z "$WRAPPER_TEST_CMD" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -z "$WRAPPER_TEST_CMD" ] +then + eval echo `gettext 'Unable to locate any of the following binaries:'` + outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" + if [ ! "$DIST_BITS" = "32" ] + then + outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" + fi + outputFile "$WRAPPER_CMD" + + exit 1 +fi + + +# Build the nice clause +if [ "X$PRIORITY" = "X" ] +then + CMDNICE="" +else + CMDNICE="nice -$PRIORITY" +fi + +# Build the anchor file clause. +if [ "X$IGNORE_SIGNALS" = "X" ] +then + ANCHORPROP= + IGNOREPROP= +else + ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\" + IGNOREPROP=wrapper.ignore_signals=TRUE +fi + +# Build the status file clause. +if [ "X$DETAIL_STATUS$WAIT_FOR_STARTED_STATUS" = "X" ] +then + STATUSPROP= +else + STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\"" +fi + +# Build the command file clause. +if [ -n "$PAUSABLE" ] +then + COMMANDPROP="wrapper.commandfile=\"$COMMANDFILE\" wrapper.pausable=TRUE" +else + COMMANDPROP= +fi + +if [ ! -n "$WAIT_FOR_STARTED_STATUS" ] +then + WAIT_FOR_STARTED_STATUS=true +fi + +if [ $WAIT_FOR_STARTED_STATUS = true ] ; then + DETAIL_STATUS=true +fi + + +# Build the lock file clause. Only create a lock file if the lock directory exists on this platform. +LOCKPROP= +if [ -d $LOCKDIR ] +then + if [ -w $LOCKDIR ] + then + LOCKPROP=wrapper.lockfile=\"$LOCKFILE\" + fi +fi + +# Build app name clause +if [ ! -n "$APP_NAME_PASS_TO_WRAPPER" ] +then + APP_NAME_PASS_TO_WRAPPER=true +fi +if [ $APP_NAME_PASS_TO_WRAPPER = false ] +then + APPNAMEPROP= +else + APPNAMEPROP="wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\"" +fi + +# Decide on run levels. +RUN_LEVEL_S_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_S_${DIST_OS}\}"` +RUN_LEVEL_S_DIST_OS=`eval "echo ${RUN_LEVEL_S_DIST_OS_TMP}"` +if [ "X${RUN_LEVEL_S_DIST_OS}" != "X" ] ; then + APP_RUN_LEVEL_S=${RUN_LEVEL_S_DIST_OS} +elif [ "X$RUN_LEVEL_S" != "X" ] ; then + APP_RUN_LEVEL_S=$RUN_LEVEL_S +else + APP_RUN_LEVEL_S=$RUN_LEVEL +fi +APP_RUN_LEVEL_S_CHECK=`echo "$APP_RUN_LEVEL_S" | sed "s/[(0-9)*]/0/g"` +if [ "X${APP_RUN_LEVEL_S_CHECK}" != "X00" ] ; then + eval echo `gettext 'Run level \"${APP_RUN_LEVEL_S}\" must be numeric and have a length of two \(00-99\).'` + exit 1; +fi +RUN_LEVEL_K_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_K_${DIST_OS}\}"` +RUN_LEVEL_K_DIST_OS=`eval "echo ${RUN_LEVEL_K_DIST_OS_TMP}"` +if [ "X${RUN_LEVEL_K_DIST_OS}" != "X" ] ; then + APP_RUN_LEVEL_K=${RUN_LEVEL_K_DIST_OS} +elif [ "X$RUN_LEVEL_K" != "X" ] ; then + APP_RUN_LEVEL_K=$RUN_LEVEL_K +else + APP_RUN_LEVEL_K=$RUN_LEVEL +fi +APP_RUN_LEVEL_K_CHECK=`echo "$APP_RUN_LEVEL_K" | sed "s/[(0-9)*]/0/g"` +if [ "X${APP_RUN_LEVEL_K_CHECK}" != "X00" ] ; then + eval echo `gettext 'Run level \"${APP_RUN_LEVEL_K}\" must be numeric and have a length of two \(00-99\).'` + exit 1; +fi + +prepAdditionalParams() { + ADDITIONAL_PARA="" + if [ ! -n "$PASS_THROUGH" ] + then + PASS_THROUGH=false + fi + if [ $PASS_THROUGH = true ] ; then + ADDITIONAL_PARA="--" + while [ -n "$1" ] ; do + ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\"" + shift + done + elif [ -n "$1" ] ; then + eval echo `gettext "WARNING: Extra arguments will be ignored. Please run \'$0 help\' for usage."` + fi +} + +checkUser() { + # $1 touchLock flag + # $2.. [command] args + + # Check the configured user. If necessary rerun this script as the desired user. + if [ "X$RUN_AS_USER" != "X" ] + then + # Resolve the location of the 'id' command + ID_BIN="/usr/xpg4/bin/id" + if [ ! -x "$ID_BIN" ] + then + ID_BIN="/usr/bin/id" + if [ ! -x "$ID_BIN" ] + then + eval echo `gettext 'Unable to locate "id".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi + fi + + if [ "`$ID_BIN -u -n`" = "$RUN_AS_USER" ] + then + # Already running as the configured user. Avoid password prompts by not calling su. + RUN_AS_USER="" + fi + fi + if [ "X$RUN_AS_USER" != "X" ] + then + if [ "`$ID_BIN -u -n "$RUN_AS_USER" 2>/dev/null`" != "$RUN_AS_USER" ] + then + eval echo `gettext 'User $RUN_AS_USER does not exist.'` + exit 1 + fi + + # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be + # able to create the lock file. The Wrapper will be able to update this file once it + # is created but will not be able to delete it on shutdown. If $1 is set then + # the lock file should be created for the current command + if [ "X$LOCKPROP" != "X" ] + then + if [ "X$1" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + touch $LOCKFILE + chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE + fi + fi + + # Still want to change users, recurse. This means that the user will only be + # prompted for a password once. Variables shifted by 1 + shift + + # Wrap the parameters so they can be passed. + ADDITIONAL_PARA="" + while [ -n "$1" ] ; do + if [ "$1" = 'installstart' ] ; then + # At this point the service is already installed. When we will fork the process we only need to start the service. + ADDITIONAL_PARA="$ADDITIONAL_PARA \"start\"" + else + ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\"" + fi + shift + done + + # Use "runuser" if this exists. + # runuser should be used on RedHat in preference to su. + if test -f "/sbin/runuser" + then + /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA" + else + $SU_BIN - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTS + fi + RUN_AS_USER_EXITCODE=$? + + # we check if the previous command has failed + if [ $RUN_AS_USER_EXITCODE -ne 0 ] + then + if [ $RUN_AS_USER_EXITCODE -eq 1 ] + then + checkForkCommand + else + eval echo `gettext 'Error executing the requested command with user \"$RUN_AS_USER\" \(error code $RUN_AS_USER_EXITCODE\).'` + echo "" + fi + fi + + # Now that we are the original user again, we may need to clean up the lock file. + if [ "X$LOCKPROP" != "X" ] + then + getpid + if [ "X$pid" = "X" ] + then + # Wrapper is not running so make sure the lock file is deleted. + if [ -f "$LOCKFILE" ] + then + rm "$LOCKFILE" + fi + fi + fi + + exit $RUN_AS_USER_EXITCODE + fi +} + +# Try to fork by executing a simple command. +# With this function, we want to make sure we are able to fork. +checkForkCommand() { + + if test -f "/sbin/runuser" + then + /sbin/runuser - $RUN_AS_USER -c "ls \"$REALPATH\"" > /dev/null 2>&1 & + else + $SU_BIN - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 & + fi + CHECK_EXITCODE=$? + + if [ $CHECK_EXITCODE -ne 0 ] + then + # clearly a problem with forking + eval echo `gettext 'Error: unable to create fork process.'` + eval echo `gettext 'Advice:'` + eval echo `gettext 'One possible cause of failure is when the user \(\"$RUN_AS_USER\"\) has no shell.'` + eval echo `gettext 'In this case, two solutions are available by editing the script file:'` + eval echo `gettext '1. Use \"SU_OPTS\" to set the shell for the user.'` + eval echo `gettext '2. Use a OS service management tool (only available on some platforms).'` + echo "" + fi +} + +getpid() { + pid="" + if [ -f "$PIDFILE" ] + then + if [ -r "$PIDFILE" ] + then + pid=`cat "$PIDFILE"` + if [ "X$pid" != "X" ] + then + if [ "X$PIDFILE_CHECK_PID" != "X" ] + then + # It is possible that 'a' process with the pid exists but that it is not the + # correct process. This can happen in a number of cases, but the most + # common is during system startup after an unclean shutdown. + # The ps statement below looks for the specific wrapper command running as + # the pid. If it is not found then the pid file is considered to be stale. + case "$DIST_OS" in + 'freebsd') + pidtest=`$PS_BIN -p $pid -o args | tail -1` + if [ "X$pidtest" = "XCOMMAND" ] + then + pidtest="" + fi + ;; + 'macosx') + pidtest=`$PS_BIN -ww -p $pid -o command | grep -F "$WRAPPER_CMD" | tail -1` + ;; + 'solaris') + if [ -f "/usr/bin/pargs" ] + then + pidtest=`pargs $pid | fgrep "$WRAPPER_CMD" | tail -1` + else + case "$PS_BIN" in + '/usr/ucb/ps') + pidtest=`$PS_BIN -auxww $pid | fgrep "$WRAPPER_CMD" | tail -1` + ;; + '/usr/bin/ps') + TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1` + ;; + '/bin/ps') + TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + fi + ;; + 'hpux') + pidtest=`$PS_BIN -p $pid -x -o args | grep -F "$WRAPPER_CMD" | tail -1` + ;; + 'zos') + TRUNCATED_CMD=`$PS_BIN -p $pid -o args | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -p $pid -o args | grep -F "$TRUNCATED_CMD" | tail -1` + ;; + *) + pidtest=`$PS_BIN -p $pid -o args | grep -F "$WRAPPER_CMD" | tail -1` + ;; + esac + else + # Check to see whether the pid exists as a running process, but in this mode, don't check what that pid is. + case "$DIST_OS" in + 'solaris') + case "$PS_BIN" in + '/usr/ucb/ps') + pidtest=`$PS_BIN $pid | grep "$pid" | awk '{print $1}' | tail -1` + ;; + '/usr/bin/ps') + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + '/bin/ps') + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + ;; + *) + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + esac + fi + + if [ "X$pidtest" = "X" ] + then + # This is a stale pid file. + rm -f "$PIDFILE" + eval echo `gettext 'Removed stale pid file: $PIDFILE'` + pid="" + fi + fi + else + eval echo `gettext 'Cannot read $PIDFILE.'` + exit 1 + fi + fi +} + +getstatus() { + STATUS= + if [ -f "$STATUSFILE" ] + then + if [ -r "$STATUSFILE" ] + then + STATUS=`cat "$STATUSFILE"` + fi + fi + if [ "X$STATUS" = "X" ] + then + STATUS="Unknown" + fi + + JAVASTATUS= + if [ -f "$JAVASTATUSFILE" ] + then + if [ -r "$JAVASTATUSFILE" ] + then + JAVASTATUS=`cat "$JAVASTATUSFILE"` + fi + fi + if [ "X$JAVASTATUS" = "X" ] + then + JAVASTATUS="Unknown" + fi +} + +testpid() { + case "$DIST_OS" in + 'solaris') + case "$PS_BIN" in + '/usr/ucb/ps') + pid=`$PS_BIN $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + '/usr/bin/ps') + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + '/bin/ps') + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + ;; + *) + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null + ;; + esac + if [ "X$pid" = "X" ] + then + # Process is gone so remove the pid file. + rm -f "$PIDFILE" + pid="" + fi +} + +launchdtrap() { + stopit + exit +} + +waitforwrapperstop() { + getpid + while [ "X$pid" != "X" ] ; do + sleep 1 + getpid + done +} + +launchinternal() { + getpid + trap launchdtrap TERM + if [ "X$pid" = "X" ] + then + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + # launchd expects that this script stay up and running so we need to do our own monitoring of the Wrapper process. + if [ $WAIT_FOR_STARTED_STATUS = true ] + then + waitforwrapperstop + fi +} + +console() { + eval echo `gettext 'Running $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + trap '' 3 + + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" $APPNAMEPROP $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi +} + +waitforjavastartup() { + getstatus + eval echo $ECHOOPT `gettext 'Waiting for $APP_LONG_NAME...$ECHOOPTC'` + + # Wait until the timeout or we have something besides Unknown. + counter=15 + while [ "$JAVASTATUS" = "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do + echo $ECHOOPT".$ECHOOPTC" + sleep 1 + getstatus + counter=`expr $counter - 1` + done + + if [ -n "$WAIT_FOR_STARTED_TIMEOUT" ] ; then + counter=$WAIT_FOR_STARTED_TIMEOUT + else + counter=120 + fi + while [ "$JAVASTATUS" != "STARTED" -a "$JAVASTATUS" != "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do + echo $ECHOOPT".$ECHOOPTC" + sleep 1 + getstatus + counter=`expr $counter - 1` + done + echo "" +} + +startwait() { + if [ $WAIT_FOR_STARTED_STATUS = true ] + then + waitforjavastartup + fi + # Sleep for a few seconds to allow for intialization if required + # then test to make sure we're still running. + # + i=0 + while [ $i -lt $WAIT_AFTER_STARTUP ] + do + sleep 1 + echo $ECHOOPT".$ECHOOPTC" + i=`expr $i + 1` + done + if [ $WAIT_AFTER_STARTUP -gt 0 -o $WAIT_FOR_STARTED_STATUS = true ] + then + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext ' WARNING: $APP_LONG_NAME may have failed to start.'` + exit 1 + else + eval echo `gettext ' running: PID:$pid'` + fi + else + echo "" + fi +} + +mustBeRootOrExit() { + if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then + eval echo `gettext 'Must be root to perform this action.'` + exit 1 + fi +} + + +macosxStart() { + # The daemon has been installed. + eval echo `gettext 'Starting $APP_LONG_NAME. Detected Mac OSX and installed launchd daemon.'` + mustBeRootOrExit + + getpid + if [ "X$pid" != "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + # If the daemon was just installed, it may not be loaded. + LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}` + if [ "X${LOADED_PLIST}" = "X" ] ; then + launchctl load /Library/LaunchDaemons/${APP_PLIST} + fi + # If launchd is set to run the daemon already at Load, we don't need to call start + getpid + if [ "X$pid" = "X" ] ; then + launchctl start ${APP_PLIST_BASE} + fi + + startwait +} + +macosxStop() { + # The daemon should be running. + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then + echo "" + eval echo `gettext 'Daemon is set to be kept continuously running and it will be automatically restarted.'` + eval echo `gettext 'To stop the daemon you need to uninstall it.'` + eval echo `gettext 'If you want to use the \"stop\" argument, you need to find MACOSX_KEEP_RUNNING'` + eval echo `gettext 'at the beginning of the script file and set it to \"false\".'` + echo "" + fi + launchctl stop ${APP_PLIST_BASE} + fi +} + +macosxRestart() { + # The daemon should be running. + eval echo `gettext 'Restarting $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then + # by stopping it, launchd will automatically restart it + launchctl stop ${APP_PLIST_BASE} + else + launchctl unload "/Library/LaunchDaemons/${APP_PLIST}" + sleep 1 + launchctl load "/Library/LaunchDaemons/${APP_PLIST}" + fi + fi + + startwait +} + +upstartstart() { + # The daemon has been installed. + eval echo `gettext 'Starting $APP_LONG_NAME. Detected Linux and installed upstart.'` + mustBeRootOrExit + + getpid + if [ "X$pid" != "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + /sbin/start ${APP_NAME} + + startwait +} + +upstartStop() { + # The daemon has been installed. + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + fi + + /sbin/stop ${APP_NAME} +} + +upstartRestart() { + # The daemon has been installed. + eval echo `gettext 'Restarting $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + fi + + /sbin/restart ${APP_NAME} + + startwait +} + +systemdInstall() { + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using systemd...'` + if [ -f "${REALDIR}/${APP_NAME}.service" ] ; then + eval echo `gettext ' a custom service file ${APP_NAME}.service found'` + cp "${REALDIR}/${APP_NAME}.service" "${SYSTEMD_SERVICE_FILE}" + else + eval echo `gettext ' creating default service file...'` + echo "[Unit]" > "${SYSTEMD_SERVICE_FILE}" + echo "Description=${APP_LONG_NAME}" >> "${SYSTEMD_SERVICE_FILE}" + echo "After=syslog.target" >> "${SYSTEMD_SERVICE_FILE}" + echo "" >> "${SYSTEMD_SERVICE_FILE}" + echo "[Service]" >> "${SYSTEMD_SERVICE_FILE}" + echo "Type=forking" >> "${SYSTEMD_SERVICE_FILE}" + echo "ExecStart=${REALPATH} start sysd" >> "${SYSTEMD_SERVICE_FILE}" + echo "ExecStop=${REALPATH} stop sysd" >> "${SYSTEMD_SERVICE_FILE}" + if [ "X${RUN_AS_USER}" != "X" ] ; then + echo "User=${RUN_AS_USER}" >> "${SYSTEMD_SERVICE_FILE}" + fi + echo "" >> "${SYSTEMD_SERVICE_FILE}" + echo "[Install]" >> "${SYSTEMD_SERVICE_FILE}" + echo "WantedBy=multi-user.target" >> "${SYSTEMD_SERVICE_FILE}" + + systemctl daemon-reload + systemctl enable "${APP_NAME}" + fi +} + +systemdStart() { + # check if the service file is present + if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then + eval echo `gettext 'Reading file ${SYSTEMD_SERVICE_FILE}'` + else + eval echo `gettext 'No service file detected. Did you install the service?'` + exit 1 + fi + + systemctl start $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to start service $APP_NAME'` + exit 1 + fi + + startwait +} + +systemdStop() { + systemctl stop $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to stop service $APP_NAME'` + exit 1 + fi +} + +systemdRestart() { + systemctl restart $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to restart service $APP_NAME'` + exit 1 + fi + + startwait +} + +systemdRemove() { + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from systemd...'` + systemctl disable $APP_NAME + rm "/etc/systemd/system/${APP_NAME}.service" + systemctl daemon-reload +} + +srcInstall() { + if [ "X$RUN_AS_USER" = "X" ] ; then + USERID="0" + else + USERID=`$ID_BIN -u "$RUN_AS_USER"` + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to get user id for $RUN_AS_USER'` + exit 1 + fi + fi + /usr/bin/mkssys -s "$APP_NAME" -p "$REALPATH" -a "launchdinternal" -u "$USERID" -f 9 -n 15 -S + /usr/sbin/mkitab "$APP_NAME":2:once:"/usr/bin/startsrc -s \"${APP_NAME}\" >/dev/console 2>&1" +} + +srcStart() { + startsrc -s "${APP_NAME}" + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to start service $APP_NAME'` + exit 1 + fi + + startwait +} + +srcStop() { + stopsrc -s "${APP_NAME}" + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to stop service $APP_NAME'` + exit 1 + fi +} + +srcRestart() { + srcStop + srcStart +} + +start() { + eval echo `gettext 'Starting $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + startwait +} + +stopit() { + # $1 exit if down flag + + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME was not running.'` + if [ "X$1" = "X1" ] + then + exit 1 + fi + else + if [ "X$IGNORE_SIGNALS" = "X" ] + then + # Running so try to stop it. + kill $pid + if [ $? -ne 0 ] + then + # An explanation for the failure should have been given + eval echo `gettext 'Unable to stop $APP_LONG_NAME.'` + exit 1 + fi + else + rm -f "$ANCHORFILE" + if [ -f "$ANCHORFILE" ] + then + # An explanation for the failure should have been given + eval echo `gettext 'Unable to stop $APP_LONG_NAME.'` + exit 1 + fi + fi + + # We can not predict how long it will take for the wrapper to + # actually stop as it depends on settings in wrapper.conf. + # Loop until it does. + savepid=$pid + CNT=0 + TOTCNT=0 + while [ "X$pid" != "X" ] + do + # Show a waiting message every 5 seconds. + if [ "$CNT" -lt "5" ] + then + CNT=`expr $CNT + 1` + else + eval echo `gettext 'Waiting for $APP_LONG_NAME to exit...'` + CNT=0 + fi + TOTCNT=`expr $TOTCNT + 1` + + sleep 1 + + testpid + done + + pid=$savepid + testpid + if [ "X$pid" != "X" ] + then + eval echo `gettext 'Failed to stop $APP_LONG_NAME.'` + exit 1 + else + eval echo `gettext 'Stopped $APP_LONG_NAME.'` + fi + fi +} + +pause() { + eval echo `gettext 'Pausing $APP_LONG_NAME.'` +} + +resume() { + eval echo `gettext 'Resuming $APP_LONG_NAME.'` +} + +status() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME is running: PID:$pid'` + else + getstatus + eval echo `gettext '$APP_LONG_NAME is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + exit 0 + fi +} + +# Make sure APP_NAME is less than 14 characters, otherwise in AIX, the command +# "lsitab" will fail +validateAppNameLength() { + if [ ${#APP_NAME} -gt 14 ] ; then + eval echo `gettext ' APP_NAME (${APP_NAME}) must be less than 14 characters long'` + exit 1 + fi +} + +installUpstart() { + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using upstart..'` + if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then + eval echo `gettext ' a custom upstart conf file ${APP_NAME}.install found'` + cp "${REALDIR}/${APP_NAME}.install" "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' creating default upstart conf file..'` + echo "# ${APP_NAME} - ${APP_LONG_NAME}" > "/etc/init/${APP_NAME}.conf" + echo "description \"${APP_LONG_NAME}\"" >> "/etc/init/${APP_NAME}.conf" + echo "author \"Tanuki Software Ltd. \"" >> "/etc/init/${APP_NAME}.conf" + echo "start on runlevel [2345]" >> "/etc/init/${APP_NAME}.conf" + echo "stop on runlevel [!2345]" >> "/etc/init/${APP_NAME}.conf" + echo "env LANG=${LANG}" >> "/etc/init/${APP_NAME}.conf" + echo "exec \"${REALPATH}\" upstartinternal" >> "/etc/init/${APP_NAME}.conf" + fi +} + +installdaemon() { + mustBeRootOrExit + + APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"` + if [ "$DIST_OS" = "solaris" ] ; then + eval echo `gettext 'Detected Solaris:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + fi + elif [ "$DIST_OS" = "linux" ] ; then + if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then + eval echo `gettext 'Detected RHEL or Fedora:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + else + if [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then + installUpstart + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + /sbin/chkconfig --add "$APP_NAME" + /sbin/chkconfig "$APP_NAME" on + fi + fi + elif [ -f /etc/SuSE-release ] ; then + eval echo `gettext 'Detected SuSE or SLES:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + insserv "/etc/init.d/$APP_NAME" + fi + elif [ -f /etc/lsb-release -o -f /etc/debian_version -o -f /etc/debian_release ] ; then + eval echo `gettext 'Detected Ubuntu or Debian:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + if [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + elif [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then + installUpstart + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using init.d..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + update-rc.d "$APP_NAME" defaults + fi + fi + else + eval echo `gettext 'Detected Linux:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" /etc/init.d/$APP_NAME + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + fi + fi + elif [ "$DIST_OS" = "hpux" ] ; then + eval echo `gettext 'Detected HP-UX:'` + if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/sbin/init.d/$APP_NAME" + for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + fi + elif [ "$DIST_OS" = "aix" ] ; then + eval echo `gettext 'Detected AIX:'` + validateAppNameLength + if [ -f "/etc/rc.d/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as rc.d script.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "`/usr/sbin/lsitab $APP_NAME`" -a -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as SRC service.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + if [ -n "`/usr/sbin/lsitab install_assist`" ] ; then + eval echo `gettext ' The task /usr/sbin/install_assist was found in the inittab, this might cause problems for all subsequent tasks to launch at this process is known to block the init task. Please make sure this task is not needed anymore and remove/deactivate it.'` + fi + for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + srcInstall + fi + elif [ "$DIST_OS" = "freebsd" ] ; then + eval echo `gettext 'Detected FreeBSD:'` + if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf + if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then + ln -s "${REALDIR}/${APP_NAME}.install" "/etc/rc.d/$APP_NAME" + else + echo '#!/bin/sh' > "/etc/rc.d/$APP_NAME" + echo "#" >> "/etc/rc.d/$APP_NAME" + echo "# PROVIDE: $APP_NAME" >> "/etc/rc.d/$APP_NAME" + echo "# REQUIRE: NETWORKING" >> "/etc/rc.d/$APP_NAME" + echo "# KEYWORD: shutdown" >> "/etc/rc.d/$APP_NAME" + echo ". /etc/rc.subr" >> "/etc/rc.d/$APP_NAME" + echo "name=\"$APP_NAME\"" >> "/etc/rc.d/$APP_NAME" + echo "rcvar=\`set_rcvar\`" >> "/etc/rc.d/$APP_NAME" + echo "command=\"${REALPATH}\"" >> "/etc/rc.d/$APP_NAME" + echo 'start_cmd="${name}_start"' >> "/etc/rc.d/$APP_NAME" + echo 'load_rc_config $name' >> "/etc/rc.d/$APP_NAME" + echo 'status_cmd="${name}_status"' >> "/etc/rc.d/$APP_NAME" + echo 'stop_cmd="${name}_stop"' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_status() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} status' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_stop() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} stop' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_start() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} start' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo 'run_rc_command "$1"' >> "/etc/rc.d/$APP_NAME" + fi + echo "${APP_NAME}_enable=\"YES\"" >> /etc/rc.conf + chmod 555 "/etc/rc.d/$APP_NAME" + fi + elif [ "$DIST_OS" = "macosx" ] ; then + eval echo `gettext 'Detected Mac OSX:'` + if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + if [ -f "${REALDIR}/${APP_PLIST}" ] ; then + ln -s "${REALDIR}/${APP_PLIST}" "/Library/LaunchDaemons/${APP_PLIST}" + else + echo "" > "/Library/LaunchDaemons/${APP_PLIST}" + echo "> "/Library/LaunchDaemons/${APP_PLIST}" + echo "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo "" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " Label" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${APP_PLIST_BASE}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ProgramArguments" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${REALPATH}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " launchdinternal" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${KEY_KEEP_ALIVE}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " <${MACOSX_KEEP_RUNNING}/>" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " RunAtLoad" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + if [ "X$RUN_AS_USER" != "X" ] ; then + echo " UserName" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${RUN_AS_USER}" >> "/Library/LaunchDaemons/${APP_PLIST}" + fi + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo "" >> "/Library/LaunchDaemons/${APP_PLIST}" + fi + chmod 555 "/Library/LaunchDaemons/${APP_PLIST}" + fi + elif [ "$DIST_OS" = "zos" ] ; then + eval echo `gettext 'Detected z/OS:'` + if [ -f /etc/rc.bak ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + cp /etc/rc /etc/rc.bak + sed "s:echo /etc/rc script executed, \`date\`::g" /etc/rc.bak > /etc/rc + echo "_BPX_JOBNAME='${APP_NAME}' \"${REALDIR}/${APP_NAME}\" start" >>/etc/rc + echo '/etc/rc script executed, `date`' >>/etc/rc + fi + else + eval echo `gettext 'Install not currently supported for $DIST_OS'` + exit 1 + fi +} + +startdaemon() { + if [ "$DIST_OS" = "macosx" ] ; then + if [ ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext 'The $APP_LONG_NAME daemon is not currently installed.'` + else + macosxStart + fi + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartstart + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdStart + elif [ "$DIST_OS" = "aix" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcStart + else + if [ -n "$SYSD" ] ; then + shift + fi + + checkUser touchlock "$@" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + start "$@" + fi +} + +removedaemon() { + mustBeRootOrExit + + APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"` + if [ "$DIST_OS" = "solaris" ] ; then + eval echo `gettext 'Detected Solaris:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "linux" ] ; then + if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then + eval echo `gettext 'Detected RHEL or Fedora:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + /sbin/chkconfig "$APP_NAME" off + /sbin/chkconfig --del "$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'` + rm "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ -f /etc/SuSE-release ] ; then + eval echo `gettext 'Detected SuSE or SLES:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + insserv -r "/etc/init.d/$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ -f /etc/lsb-release -o -f /etc/debian_version -o -f /etc/debian_release ] ; then + eval echo `gettext 'Detected Ubuntu or Debian:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from init.d...'` + update-rc.d -f "$APP_NAME" remove + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'` + rm "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + else + eval echo `gettext 'Detected Linux:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + fi + elif [ "$DIST_OS" = "hpux" ] ; then + eval echo `gettext 'Detected HP-UX:'` + if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" "/sbin/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "aix" ] ; then + eval echo `gettext 'Detected AIX:'` + validateAppNameLength + if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -L "/etc/rc.d/init.d/$APP_NAME" -o -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -L "/etc/rc.d/init.d/$APP_NAME" ] ; then + for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" "/etc/rc.d/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + fi + if [ -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + /usr/sbin/rmitab $APP_NAME + /usr/bin/rmssys -s $APP_NAME + fi + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "freebsd" ] ; then + eval echo `gettext 'Detected FreeBSD:'` + if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in "/etc/rc.d/$APP_NAME" + do + rm -f $i + done + sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "macosx" ] ; then + eval echo `gettext 'Detected Mac OSX:'` + if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + # Make sure the plist is installed + LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}` + if [ "X${LOADED_PLIST}" != "X" ] ; then + launchctl unload "/Library/LaunchDaemons/${APP_PLIST}" + fi + rm -f "/Library/LaunchDaemons/${APP_PLIST}" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "zos" ] ; then + eval echo `gettext 'Detected z/OS:'` + if [ -f /etc/rc.bak ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + cp /etc/rc /etc/rc.bak + sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc + rm /etc/rc.bak + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + else + eval echo `gettext 'Remove not currently supported for $DIST_OS'` + exit 1 + fi +} + +dump() { + eval echo `gettext 'Dumping $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME was not running.'` + else + kill -3 $pid + + if [ $? -ne 0 ] + then + eval echo `gettext 'Failed to dump $APP_LONG_NAME.'` + exit 1 + else + eval echo `gettext 'Dumped $APP_LONG_NAME.'` + fi + fi +} + +# Used by HP-UX init scripts. +startmsg() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Stopped'` + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Running'` + else + getstatus + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + fi +} + +# Used by HP-UX init scripts. +stopmsg() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Stopped'` + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Running'` + else + getstatus + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + fi +} + +showUsage() { + # $1 bad command + + if [ -n "$1" ] + then + eval echo `gettext 'Unexpected command: $1'` + echo ""; + fi + + eval MSG=`gettext 'Usage: '` + if [ -n "$FIXED_COMMAND" ] ; then + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 {JavaAppArgs}" + else + echo "${MSG} $0" + fi + else + if [ -n "$PAUSABLE" ] ; then + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | pause | resume | status | install | installstart | remove | dump ]" + else + echo "${MSG} $0 [ console | start | stop | restart | condrestart | pause | resume | status | install | installstart | remove | dump ]" + fi + else + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | status | install | installstart | remove | dump ]" + else + echo "${MSG} $0 [ console | start | stop | restart | condrestart | status | install | installstart | remove | dump ]" + fi + fi + fi + + if [ ! -n "$BRIEF_USAGE" ] + then + echo ""; + if [ ! -n "$FIXED_COMMAND" ] ; then + echo "`gettext 'Commands:'`" + echo "`gettext ' console Launch in the current console.'`" + echo "`gettext ' start Start in the background as a daemon process.'`" + echo "`gettext ' stop Stop if running as a daemon or in another console.'`" + echo "`gettext ' restart Stop if running and then start.'`" + echo "`gettext ' condrestart Restart only if already running.'`" + if [ -n "$PAUSABLE" ] ; then + echo "`gettext ' pause Pause if running.'`" + echo "`gettext ' resume Resume if paused.'`" + fi + echo "`gettext ' status Query the current status.'`" + echo "`gettext ' install Install to start automatically when system boots.'`" + echo "`gettext ' installstart Install and start running as a daemon process.'`" + echo "`gettext ' remove Uninstall.'`" + echo "`gettext ' dump Request a Java thread dump if running.'`" + echo ""; + fi + if [ -n "$PASS_THROUGH" ] ; then + echo "`gettext 'JavaAppArgs: Zero or more arguments which will be passed to the Java application.'`" + echo ""; + fi + fi + + exit 1 +} + +docommand() { + case "$COMMAND" in + 'console') + checkUser touchlock "$@" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + console "$@" + ;; + + 'start') + startdaemon "$@" + ;; + + 'stop') + if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + macosxStop + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartStop + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdStop + elif [ "$DIST_OS" = "aix" ] && [ "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcStop + else + checkUser "" "$COMMAND" + stopit "0" + fi + ;; + + 'restart') + if [ "$DIST_OS" = "macosx" ] ; then + if [ ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext '$APP_NAME was not installed.'` + else + macosxRestart + fi + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartRestart + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdRestart + elif [ "$DIST_OS" = "aix" ] && [ "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcRestart + else + if [ -n "$SMF" ] ; then + shift + fi + checkUser touchlock "$COMMAND" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + stopit "0" + start "$@" + fi + ;; + + 'condrestart') + checkUser touchlock "$COMMAND" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + stopit "1" + start "$@" + ;; + + 'pause') + if [ -n "$PAUSABLE" ] + then + pause + else + showUsage "$COMMAND" + fi + ;; + + 'resume') + if [ -n "$PAUSABLE" ] + then + resume + else + showUsage "$COMMAND" + fi + ;; + + 'status') + status + ;; + + 'install') + installdaemon "$@" + ;; + + 'installstart') + installdaemon "$@" + startdaemon "$@" + ;; + + 'remove') + removedaemon + ;; + + 'dump') + checkUser "" "$COMMAND" + dump + ;; + + 'start_msg') + # Internal command called by launchd on HP-UX. + checkUser "" "$COMMAND" + startmsg + ;; + + 'stop_msg') + # Internal command called by launchd on HP-UX. + checkUser "" "$COMMAND" + stopmsg + ;; + + 'launchdinternal' | 'upstartinternal') + if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + checkUser touchlock "$@" + fi + # Internal command called by launchd on Max OSX. + # We do not want to call checkUser here as it is handled in the launchd plist file. Doing it here would confuse launchd. + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + launchinternal "$@" + ;; + + *) + showUsage "$COMMAND" + ;; + esac +} + +docommand "$@" + +exit 0 diff --git a/food-mq/src/main/bin/pause.bat b/food-mq/src/main/bin/pause.bat new file mode 100644 index 0000000..65a2166 --- /dev/null +++ b/food-mq/src/main/bin/pause.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -a %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -a %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/query.bat b/food-mq/src/main/bin/query.bat new file mode 100644 index 0000000..5638a44 --- /dev/null +++ b/food-mq/src/main/bin/query.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -q %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -q %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/resume.bat b/food-mq/src/main/bin/resume.bat new file mode 100644 index 0000000..8b4d6ea --- /dev/null +++ b/food-mq/src/main/bin/resume.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -e %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -e %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/run.bat b/food-mq/src/main/bin/run.bat new file mode 100644 index 0000000..8672708 --- /dev/null +++ b/food-mq/src/main/bin/run.bat @@ -0,0 +1,156 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. +rem +rem ******************************************************************** +rem NOTE - This script has been modified to run the TestWrapper sample +rem application and should NOT be used as a base for your own +rem applications. All of the documentation assumes that you are +rem working from the default source script: +rem WRAPPER_HOME/src/bin/App.bat.in +rem ******************************************************************** +rem +rem ******************************************************************** +rem NOTE - This script has been modified to run the TestWrapper sample +rem application and should NOT be used as a base for your own +rem applications. All of the documentation assumes that you are +rem working from the default source script: +rem WRAPPER_HOME/src/bin/App.bat.in +rem ******************************************************************** + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM +rem as is. +rem If _WRAPPER_CONF_OVERRIDE is specified then all parameters will be passed. +rem If not set then all parameters starting with the second will be passed. +set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/food-mq/src/main/bin/start.bat b/food-mq/src/main/bin/start.bat new file mode 100644 index 0000000..d7d5e85 --- /dev/null +++ b/food-mq/src/main/bin/start.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -t %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -t %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/stop.bat b/food-mq/src/main/bin/stop.bat new file mode 100644 index 0000000..49d717c --- /dev/null +++ b/food-mq/src/main/bin/stop.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -p %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -p %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/uninstall.bat b/food-mq/src/main/bin/uninstall.bat new file mode 100644 index 0000000..6ee6d07 --- /dev/null +++ b/food-mq/src/main/bin/uninstall.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/src/main/bin/wrapper-linux-x86-32 b/food-mq/src/main/bin/wrapper-linux-x86-32 new file mode 100644 index 0000000..ff3509f Binary files /dev/null and b/food-mq/src/main/bin/wrapper-linux-x86-32 differ diff --git a/food-mq/src/main/bin/wrapper-linux-x86-64 b/food-mq/src/main/bin/wrapper-linux-x86-64 new file mode 100644 index 0000000..e72b0e0 Binary files /dev/null and b/food-mq/src/main/bin/wrapper-linux-x86-64 differ diff --git a/food-mq/src/main/bin/wrapper-macosx-universal-32 b/food-mq/src/main/bin/wrapper-macosx-universal-32 new file mode 100644 index 0000000..9a36a5c Binary files /dev/null and b/food-mq/src/main/bin/wrapper-macosx-universal-32 differ diff --git a/food-mq/src/main/bin/wrapper-macosx-universal-64 b/food-mq/src/main/bin/wrapper-macosx-universal-64 new file mode 100644 index 0000000..6587d2c Binary files /dev/null and b/food-mq/src/main/bin/wrapper-macosx-universal-64 differ diff --git a/food-mq/src/main/bin/wrapper-windows-x86-32.exe b/food-mq/src/main/bin/wrapper-windows-x86-32.exe new file mode 100644 index 0000000..9762dbf Binary files /dev/null and b/food-mq/src/main/bin/wrapper-windows-x86-32.exe differ diff --git a/food-mq/src/main/bin/wrapper-windows-x86-64.exe b/food-mq/src/main/bin/wrapper-windows-x86-64.exe new file mode 100644 index 0000000..122ec17 Binary files /dev/null and b/food-mq/src/main/bin/wrapper-windows-x86-64.exe differ diff --git a/food-mq/src/main/conf/wrapper.conf b/food-mq/src/main/conf/wrapper.conf new file mode 100644 index 0000000..93620a2 --- /dev/null +++ b/food-mq/src/main/conf/wrapper.conf @@ -0,0 +1,60 @@ +encoding=UTF-8 +wrapper.lang=zh_CN +#using the system default JDK environment variable +wrapper.java.command=java +#set.JAVA_HOME=/home/jdk1.8.0_65 +#wrapper.java.command=%JAVA_HOME%/bin/java +wrapper.java.command.loglevel=INFO + +wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp +wrapper.java.classpath.1=./ +wrapper.java.classpath.2=../conf/ +wrapper.java.classpath.3=../lib/*.jar + +wrapper.java.library.path.1=../lib + +wrapper.java.additional.auto_bits=TRUE +#set the default parameters +wrapper.java.additional.1=-Xms512m +wrapper.java.additional.2=-Xmx1024m +wrapper.java.additional.3=-XX:PermSize=256m +wrapper.java.additional.4=-XX:MaxPermSize=512m +wrapper.java.additional.5=-Djava.net.preferIPv4Stack=true +wrapper.java.additional.6=-Dsun.lang.ClassLoader.allowArraySyntax=true + +# Initial Java Heap Size (in MB) +wrapper.java.initmemory=128 +# Maximum Java Heap Size (in MB) +wrapper.java.maxmemory=512 + +# Application parameters. Add parameters as needed starting from 1 +wrapper.app.parameter.1=org.springframework.boot.loader.JarLauncher +wrapper.app.parameter.2=--spring.config.location=../conf/application.properties +wrapper.app.parameter.3=--logging.config=../conf/logback.xml +wrapper.app.parameter.4=--logging.path=../logs + +wrapper.filter.trigger.1=java.lang.OutOfMemoryError +wrapper.filter.action.1=RESTART + +wrapper.console.format=PM +wrapper.console.loglevel=INFO + +wrapper.logfile=../logs/mq_YYYYMMDD.log +wrapper.logfile.rollmode=DATE +wrapper.logfile.format=LPTM +wrapper.logfile.loglevel=INFO +wrapper.logfile.maxsize=0 +wrapper.logfile.maxfiles=0 +wrapper.syslog.loglevel=NONE + +wrapper.ignore_sequence_gaps=TRUE +wrapper.pidfile.strict=TRUE + +wrapper.console.title=estore mq application + +wrapper.name=estore_mq +wrapper.displayname=estore mq application +wrapper.description=estore mq application +wrapper.ntservice.dependency.1= +wrapper.ntservice.starttype=AUTO_START +wrapper.ntservice.interactive=false diff --git a/food-mq/src/main/java/com/jwsaas/Application.java b/food-mq/src/main/java/com/jwsaas/Application.java new file mode 100644 index 0000000..82cf31d --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/Application.java @@ -0,0 +1,15 @@ +package com.jwsaas; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@ComponentScan(basePackages = "com.jwsaas") +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/Constant.java b/food-mq/src/main/java/com/jwsaas/Constant.java new file mode 100644 index 0000000..cd99c67 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/Constant.java @@ -0,0 +1,30 @@ +package com.jwsaas; + +public class Constant { + + /** + * 系统默认数据源标识 + */ + public static final String DEFAULT_DB_SIGN = "10001"; + + /** + * 系统默认创建人 + */ + public static final String CREATE_USER = "OpenApi"; + + /** + * 系统默认redis前缀 + */ + public static final String DEFAULT_REDIS_PREFIX = "food20OpenApi"; + + /** + * 公共部分标识(shared) + */ + public static final String SHARED_SIGN = "shared"; + + /** + * 餐饮项目标识(food2) + */ + public static final String FOOD_SIGN = "food2"; + +} diff --git a/food-mq/src/main/java/com/jwsaas/RabbitConstant.java b/food-mq/src/main/java/com/jwsaas/RabbitConstant.java new file mode 100644 index 0000000..2e4af0b --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/RabbitConstant.java @@ -0,0 +1,29 @@ +package com.jwsaas; + +public class RabbitConstant { + + public final static String EXCHANGE_NAME = "exchange";// 交换器 + + public final static String QUEUE_NAME_POS_MONITOR = "queue4posmonitor";// POS监控 + + public final static String QUEUE_NAME_ORDER_BURDEN = "queue4orderburden";// 订单库存耗料 + + public final static String QUEUE_NAME_BUSINESS_ORDER_PLUS = "queue4businessorderplus";// 销售数据上传 + + public final static String ROUTING_KEY_BUSINESS_ORDER_PLUS = "routing4businessorderplus";// 销售数据上传 + + public final static String QUEUE_NAME_BUSLOG = "queue4buslog";// 操作日志数据上传 + + public final static String QUEUE_NAME_PRODUCT_SALE_STOCK = "queue4productsalestock";// 商品库存扣减 + + public final static String QUEUE_NAME_PROGRAM_SALE_STOCK = "queue4programsalestock";// 小程序商品库存扣减 + + public static final String QUEUE_NAME_BUSINESS_ORDER_PLUS_DELAY = "queue4businessorderplus4delay";//销售数据延时上传 + + public static final String ROUTING_KEY_BUSINESS_ORDER_PLUS_DELAY = "routingkey4businessorderplusdelay";// + + public static final String ROUTING_KEY_JW_PROGRAM_ORDER_NOTIFY_DELAY = "routing4jwprogramordernotifydelay";//巨为小程序订单延时推送 + public static final String QUEUE_NAME_JW_PROGRAM_ORDER_DELAY = "queue4jwprogramorderdelay";//巨为小程序订单推送延时队列; + public static final String ROUTING_KEY_JW_PROGRAM_ORDER_NOTIFY = "routing4jwprogramordernotify";//巨为小程序订单推送; + public static final String QUEUE_NAME_JW_PROGRAM_ORDER_NOTIFY = "queue4jwprogramordernotify";//巨为小程序订单推送队列; +} diff --git a/food-mq/src/main/java/com/jwsaas/config/DubboSupport.java b/food-mq/src/main/java/com/jwsaas/config/DubboSupport.java new file mode 100644 index 0000000..619f835 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/config/DubboSupport.java @@ -0,0 +1,91 @@ +package com.jwsaas.config; + +import org.springframework.stereotype.Component; + +import com.alibaba.dubbo.config.annotation.Reference; +import com.jwsaas.cache.CacheService; +import com.jwsaas.service.food.PosInfoService; +import com.jwsaas.service.food.ProductStoreStockService; +import com.jwsaas.service.food.ProgramStoreOrderProductService; +import com.jwsaas.service.food.ProgramStoreProductService; +import com.jwsaas.service.food.StoreBusinessTicketService; +import com.jwsaas.service.food.StoreOperationLogService; +import com.jwsaas.service.food.StoreProductSaleStockService; +import com.jwsaas.service.food.StoreProductService; +import com.jwsaas.service.ops.TenantPosInfoService; +import com.jwsaas.service.ops.TenantStoreAuthService; + +@Component +public class DubboSupport { + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private CacheService cacheService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private TenantPosInfoService tenantPosInfoService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private TenantStoreAuthService tenantStoreAuthService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private PosInfoService posInfoService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private ProductStoreStockService productStoreStockService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private StoreBusinessTicketService storeBusinessTicketService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private StoreOperationLogService storeOperationLogService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private StoreProductSaleStockService storeProductSaleStockService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private StoreProductService storeProductService; + + @Reference(group = "${food.service.group}", version = "${food.service.version}", application = "${dubbo.application.id}", consumer = "${dubbo.consumer.id}", registry = "${dubbo.registry.id}") + private ProgramStoreOrderProductService programStoreOrderProductService; + + public CacheService getCacheService() { + return cacheService; + } + + public TenantPosInfoService getTenantPosInfoService() { + return tenantPosInfoService; + } + + public TenantStoreAuthService getTenantStoreAuthService() { + return tenantStoreAuthService; + } + + public PosInfoService getPosInfoService() { + return posInfoService; + } + + public ProductStoreStockService getProductStoreStockService() { + return productStoreStockService; + } + + public StoreBusinessTicketService getStoreBusinessTicketService() { + return storeBusinessTicketService; + } + + public StoreOperationLogService getStoreOperationLogService() { + return storeOperationLogService; + } + + public StoreProductSaleStockService getStoreProductSaleStockService() { + return storeProductSaleStockService; + } + + public StoreProductService getStoreProductService() { + return storeProductService; + } + + public ProgramStoreOrderProductService getProgramStoreOrderProductService() { + return programStoreOrderProductService; + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/config/ExpirationMessagePostProcessor.java b/food-mq/src/main/java/com/jwsaas/config/ExpirationMessagePostProcessor.java new file mode 100644 index 0000000..3e9d4d0 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/config/ExpirationMessagePostProcessor.java @@ -0,0 +1,27 @@ +package com.jwsaas.config; + +import org.springframework.amqp.AmqpException; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessagePostProcessor; + +/** + * 延时队列使用 + * @author yangaming + * + */ +public class ExpirationMessagePostProcessor implements MessagePostProcessor { + + private final Long ttl;//毫秒 + + public ExpirationMessagePostProcessor(Long ttl) { + this.ttl = ttl; + } + + + @Override + public Message postProcessMessage(Message message) throws AmqpException { + message.getMessageProperties().setExpiration(ttl.toString()); + return message; + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/config/MQMessageSender.java b/food-mq/src/main/java/com/jwsaas/config/MQMessageSender.java new file mode 100644 index 0000000..e8d15c6 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/config/MQMessageSender.java @@ -0,0 +1,38 @@ +package com.jwsaas.config; + +import com.jwsaas.RabbitConstant; +import com.jwsaas.util.JSONUtil; +import org.springframework.amqp.core.MessagePostProcessor; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.rabbit.support.CorrelationData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class MQMessageSender { + + @Autowired + private RabbitTemplate rabbitTemplate; + + /** + * 发送消息到send4businessorderplus队列(销售数据上传队列,延迟队列) + */ + public void send4businessorderplus(String tenantId, Map message, CorrelationData correlationData, long ttl) throws Exception { + message.put("tenantId", tenantId); + MessagePostProcessor msgPostProcessor = new ExpirationMessagePostProcessor(ttl); + this.rabbitTemplate.convertAndSend(RabbitConstant.EXCHANGE_NAME, RabbitConstant.ROUTING_KEY_BUSINESS_ORDER_PLUS_DELAY, JSONUtil.toJSONString(message), msgPostProcessor, correlationData); + } + + /** + * 发送消息到send4jwprogramordermessage队列(巨为点餐小程序订单推送,延迟队列) + */ + public void send4jwprogramordermessage(String tenantId, Map message, CorrelationData correlationData, long ttl) throws Exception { + message.put("tenantId", tenantId); + MessagePostProcessor msgPostProcessor = new ExpirationMessagePostProcessor(ttl); + this.rabbitTemplate.convertAndSend(RabbitConstant.EXCHANGE_NAME, RabbitConstant.ROUTING_KEY_JW_PROGRAM_ORDER_NOTIFY_DELAY, JSONUtil.toJSONString(message), msgPostProcessor, correlationData); + } + + +} diff --git a/food-mq/src/main/java/com/jwsaas/config/RabbitMQConfig.java b/food-mq/src/main/java/com/jwsaas/config/RabbitMQConfig.java new file mode 100644 index 0000000..f607a2f --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/config/RabbitMQConfig.java @@ -0,0 +1,874 @@ +package com.jwsaas.config; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.jwsaas.cache.CacheService; +import com.jwsaas.mqtt.MqttClientExt; +import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.amqp.core.*; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; +import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; +import org.springframework.amqp.rabbit.support.CorrelationData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.jwsaas.Constant; +import com.jwsaas.RabbitConstant; +import com.jwsaas.condition.Criteria; +import com.jwsaas.condition.Restrictions; +import com.jwsaas.entity.food.BusinessOrderUpload; +import com.jwsaas.entity.food.PosInfo; +import com.jwsaas.entity.food.ProductStoreStockLog; +import com.jwsaas.entity.food.ProgramStoreOrderProduct; +import com.jwsaas.entity.food.StoreBusinessTicket; +import com.jwsaas.entity.food.StoreBusinessTicketCheck; +import com.jwsaas.entity.food.StoreBusinessTicketDelivery; +import com.jwsaas.entity.food.StoreBusinessTicketInfo; +import com.jwsaas.entity.food.StoreOperationLog; +import com.jwsaas.entity.food.StoreOrderProduct; +import com.jwsaas.entity.food.StoreOrderProductInfo; +import com.jwsaas.entity.food.StoreOrderProductMake; +import com.jwsaas.entity.food.StorePay; +import com.jwsaas.entity.ops.TenantPosInfo; +import com.jwsaas.entity.ops.TenantStoreAuth; +import com.jwsaas.service.food.PosInfoService; +import com.jwsaas.service.food.ProductStoreStockService; +import com.jwsaas.service.food.ProgramStoreOrderProductService; +import com.jwsaas.service.food.StoreBusinessTicketService; +import com.jwsaas.service.food.StoreOperationLogService; +import com.jwsaas.service.food.StoreProductSaleStockService; +import com.jwsaas.service.food.StoreProductService; +import com.jwsaas.service.ops.TenantPosInfoService; +import com.jwsaas.service.ops.TenantStoreAuthService; +import com.jwsaas.util.JSONUtil; +import com.jwsaas.utils.DateUtils; +import com.rabbitmq.client.Channel; + +import javax.annotation.Resource; + +@Configuration +public class RabbitMQConfig { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Value("${spring.rabbitmq.host}") + private String host; + + @Value("${spring.rabbitmq.port}") + private String port; + + @Value("${spring.rabbitmq.username}") + private String username; + + @Value("${spring.rabbitmq.password}") + private String password; + + @Value("${spring.rabbitmq.publisherConfirms}") + private Boolean publisherConfirms; + + @Value("${spring.rabbitmq.virtualHost}") + private String virtualHost; + + @Autowired + private DubboSupport dubboSupport; + + @Autowired + private MQMessageSender mqMessageSender; + + @Resource + private MqttClientExt mqttClient; + + private final static String DISABLED_BODUO_TENANTID_STRS = ""; + + // 创建工厂连接 + @Bean + public ConnectionFactory connectionFactory() { + CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); + connectionFactory.setAddresses(this.host); + connectionFactory.setUsername(this.username); + connectionFactory.setPassword(this.password); + connectionFactory.setVirtualHost(this.virtualHost); + connectionFactory.setPublisherConfirms(this.publisherConfirms); // 必须要设置 + connectionFactory.setChannelCacheSize(100); + return connectionFactory; + } + + // 直连交换机 + @Bean + public DirectExchange defaultExchange() { + return new DirectExchange(RabbitConstant.EXCHANGE_NAME); + } + + // 队列-POS监控 + @Bean(name = "queue4posmonitor") + public Queue queue4posmonitor() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_POS_MONITOR).build(); + } + + @Bean(name = "messageContainer4posmonitor") + public SimpleMessageListenerContainer messageContainer4posmonitor() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + // container.setTaskExecutor(taskExecutor); + container.setQueues(this.queue4posmonitor()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(10); + container.setConcurrentConsumers(5); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.debug("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + TenantPosInfo tenantPosInfo = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("tenantPosInfo")), new TypeReference() { + }); + logger.debug("tenantId:" + tenantId); + logger.debug("type:" + type); + logger.debug("tenantPosInfo:" + tenantPosInfo); + + TenantPosInfoService tenantPosInfoService = dubboSupport.getTenantPosInfoService(); + + TenantStoreAuthService tenantStoreAuthService = dubboSupport.getTenantStoreAuthService(); + + PosInfoService posInfoService = dubboSupport.getPosInfoService(); + + Date currentDate = new Date(); + int rows = tenantPosInfoService.updateMonitorInfo(Constant.DEFAULT_DB_SIGN, tenantPosInfo); + List listAuth = tenantStoreAuthService.findList(Constant.DEFAULT_DB_SIGN, "storeId", tenantPosInfo.getStoreId()); + if (listAuth != null) { + for (TenantStoreAuth auth : listAuth) { + auth.setLastDate(DateUtils.format(currentDate, "yyyy-MM-dd HH:mm:ss")); + tenantStoreAuthService.update(Constant.DEFAULT_DB_SIGN, auth); + } + } + logger.debug("rows:" + rows); + if (rows == 0) { + saveMissPos(tenantId, tenantPosInfoService, posInfoService, tenantPosInfo.getStoreId(), tenantPosInfo.getPosNo()); + } + + logger.info("MQ消息(POS监控信息)处理完成--->[{},{},{}]", tenantId, type, currentDate); + } catch (Exception e) { + logger.error("MQ消息(POS监控信息)处理发生异常", e); + } + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } + + }); + return container; + } + + /** + * 遗漏POS信息处理 + */ + private void saveMissPos(String tenantId, TenantPosInfoService tenantPosInfoService, PosInfoService posInfoService, String storeId, String posNo) { + String info = "遗漏POS信息处理"; + logger.debug(">>>>>>>" + info + "。。。"); + logger.debug("tenantId:" + tenantId); + logger.debug("storeId:" + storeId); + logger.debug("posNo:" + posNo); + + try { + Criteria criteria = new Criteria(); + criteria.add(Restrictions.eq("storeId", storeId)); + criteria.add(Restrictions.eq("posNo", posNo)); + List posInfoList = posInfoService.getList(tenantId, criteria); + if (CollectionUtils.isNotEmpty(posInfoList)) { + PosInfo posInfo = posInfoList.get(0); + TenantPosInfo tenantPosInfo = new TenantPosInfo(); + tenantPosInfo.setAppSign(posInfo.getAppSign()); + tenantPosInfo.setCpuNumber(posInfo.getCpuNumber()); + tenantPosInfo.setDeleteFlag(posInfo.getDeleteFlag()); + tenantPosInfo.setDescription(posInfo.getDescription()); + tenantPosInfo.setMACAddress(posInfo.getMACAddress()); + tenantPosInfo.setName(posInfo.getName()); + tenantPosInfo.setPosNo(posInfo.getPosNo()); + tenantPosInfo.setSerialNumber(posInfo.getSerialNumber()); + tenantPosInfo.setStatus(0); + tenantPosInfo.setStoreId(posInfo.getStoreId()); + tenantPosInfo.setStoreNo(posInfo.getStoreNo()); + tenantPosInfo.setTenantCode(tenantId); + tenantPosInfo.setTenantId(Constant.DEFAULT_DB_SIGN); + tenantPosInfo.setTerminalType(posInfo.getTerminalType()); + tenantPosInfo.setCreateDate(posInfo.getCreateDate()); + tenantPosInfo.setCreateUser(posInfo.getCreateUser()); + tenantPosInfo.setStoreName(null); + tenantPosInfo.setAliasName(posInfo.getAliasName());// 别名 + tenantPosInfoService.save(Constant.DEFAULT_DB_SIGN, tenantPosInfo); + } + } catch (Exception e) { + logger.error(info + ",发生异常", e); + } + } + + // 队列-销售耗料 + @Bean(name = "queue4orderburden") + public Queue queue4orderburden() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_ORDER_BURDEN).build(); + } + + @Bean(name = "messageContainer4orderburden") + public SimpleMessageListenerContainer messageContainer4orderburden() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + // container.setTaskExecutor(taskExecutor); + container.setQueues(this.queue4orderburden()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(1); + container.setConcurrentConsumers(1); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.debug("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + + List stockList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("stockList")), new TypeReference>() { + }); + logger.debug("tenantId:" + tenantId); + logger.debug("type:" + type); + logger.debug("stockList:" + stockList); + Date currentDate = new Date(); + + ProductStoreStockService productStoreStockService = dubboSupport.getProductStoreStockService(); + productStoreStockService.saveStockOutBySalesOrder(tenantId, stockList); + logger.info("MQ消息(库存耗料数据)处理完成--->[{},{},{}]", tenantId, type, currentDate); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } catch (Exception e) { + logger.error("MQ消息(库存耗料数据)处理发生异常", e); + } + } + + }); + return container; + } + + // 队列-销售数据上传 + @Bean(name = "queue4businessorderplus") + public Queue queue4businessorderplus() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_BUSINESS_ORDER_PLUS).build(); + } + + @Bean(name = "messageContainer4businessorderplus") + public SimpleMessageListenerContainer messageContainer4businessorderplus() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + // container.setTaskExecutor(taskExecutor); + container.setQueues(this.queue4businessorderplus()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(10); + container.setConcurrentConsumers(10); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.debug("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + StoreBusinessTicket storeBusinessTicket = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("storeBusinessTicket")), new TypeReference() { + }); + List ticketInfoList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("ticketInfoList")), new TypeReference>() { + }); + List orderProductList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("orderProductList")), new TypeReference>() { + }); + for (StoreOrderProduct storeOrderProduct : orderProductList) { + storeOrderProduct.setProductName(filter(storeOrderProduct.getProductName())); + } + List orderProductInfoList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("orderProductInfoList")), new TypeReference>() { + }); + List payList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("payList")), new TypeReference>() { + }); + List makeList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("makeList")), new TypeReference>() { + }); + List deliveryList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("deliveryList")), new TypeReference>() { + }); + storeBusinessTicket.setId(null); + storeBusinessTicket.setCreateDate(null); + logger.debug("tenantId:" + tenantId); + logger.debug("type:" + type); + logger.debug("storeBusinessTicket:" + storeBusinessTicket); + logger.debug("ticketInfoList:" + ticketInfoList); + logger.debug("orderProductList:" + orderProductList); + logger.debug("orderProductInfoList:" + orderProductInfoList); + logger.debug("payList:" + payList); + logger.debug("makeList:" + makeList); + logger.debug("deliveryList:" + deliveryList); + Date currentDate = new Date(); + StoreBusinessTicketService storeBusinessTicketService = dubboSupport.getStoreBusinessTicketService(); + Map extData = new HashMap<>(); + if (storeBusinessTicket.getBusMode() == 2) { + // 门店外送单 + // 营业模式,busMode,0 柜台-1 外带-2 电话外卖 + // 3-餐桌4-美团外卖5-饿了么6-百度外卖7-微信点餐 + // 单据状态,status,0等待付款1已支付2已退单3已取消4已完成 + Criteria criteria = new Criteria(); + criteria.add(Restrictions.eq("storeId", storeBusinessTicket.getStoreId())); + criteria.add(Restrictions.eq("`no`", storeBusinessTicket.getNo())); + criteria.add(Restrictions.order("saleDate", "DESC")); + List ticketList = storeBusinessTicketService.getList(tenantId, criteria); + logger.debug("============ticketList:" + JSONUtil.toJSONString(ticketList)); + + List ticketIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(ticketList)) { + for (StoreBusinessTicket ticket : ticketList) { + ticketIdList.add(ticket.getId()); + } + } + extData.put("ticketIdList", ticketIdList); + } + BusinessOrderUpload businessOrderUpload = new BusinessOrderUpload(); + businessOrderUpload.setTicket(storeBusinessTicket); + businessOrderUpload.setTicketInfos(ticketInfoList); + businessOrderUpload.setProducts(orderProductList); + businessOrderUpload.setProductInfos(orderProductInfoList); + businessOrderUpload.setPays(payList); + businessOrderUpload.setMakes(makeList); + businessOrderUpload.setDeliveryInfos(deliveryList); + // 保存上传数据 + + StoreBusinessTicketCheck ticketCheck = storeBusinessTicketService.saveBusinessTicketPlus(tenantId, businessOrderUpload, extData); + if ("1".equals(ticketCheck.getStatus())) { + // 保存成功之后的事件处理 + if (storeBusinessTicket.getBusMode() == 2) { + if (storeBusinessTicket.getStatus() != 0) { + // 在这儿处理门店外送(外卖)订单重复上传的问题 + List ticketIdList = (List) extData.get("ticketIdList"); + if (CollectionUtils.isNotEmpty(ticketIdList)) { + String storeId = storeBusinessTicket.getStoreId(); + String ticketNo = storeBusinessTicket.getNo(); + for (String tempTicketId : ticketIdList) { + try { + storeBusinessTicketService.updateTicketToInvalid(tenantId, storeId, tempTicketId, ticketNo); + } catch (Exception e) { + logger.error("MQ消息(销售数据上传)(updateTicketToInvalid操作),发生异常[{},{},{},{}]", tenantId, storeId, tempTicketId, ticketNo); + logger.error("MQ消息(销售数据上传)(updateTicketToInvalid操作),发生异常", e); + CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); + try{ + mqMessageSender.send4businessorderplus(tenantId,dataMap,correlationData,1000L*60*10);//延时10分钟; + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + }catch (Exception ex){ + logger.error("MQ消息(销售数据上传,updateTicketToInvalid操作,延时队列报错)处理发生异常", ex); + } + } + } + } + } + } + logger.info("MQ消息(销售数据上传)处理完成--->[{},{},{}]", tenantId, type, currentDate); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } else { + logger.error("MQ消息(销售数据上传)服务器繁忙,重新处理--->[{},{},{}]", tenantId, type, currentDate); + CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); + try{ + mqMessageSender.send4businessorderplus(tenantId,dataMap,correlationData,1000L*60*10);//延时10分钟; + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + }catch (Exception e){ + logger.error("MQ消息(销售数据上传,未接收到消息处,延时队列报错)处理发生异常", e); + } + + } + } catch (Exception e) { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.info("receive msg : " + bodyContent); + logger.error("MQ消息(销售数据上传)处理发生异常", e); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + + String tenantId = dataMap.get("tenantId").toString(); + CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); + try{ + mqMessageSender.send4businessorderplus(tenantId,dataMap,correlationData,1000L*60*10);//延时10分钟; + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + }catch (Exception ex){ + logger.error("MQ消息(销售数据上传,未接收到消息------catch---处,延时队列报错)处理发生异常", ex); + } + + } + } + + }); + return container; + } + + // 队列-操作日志上传 + @Bean(name = "queue4buslog") + public Queue queue4buslog() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_BUSLOG).build(); + } + + @Bean(name = "messageContainer4buslog") + public SimpleMessageListenerContainer messageContainer4buslog() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + container.setQueues(this.queue4buslog()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(1); + container.setConcurrentConsumers(1); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.debug("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + + List logList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("buslog")), new TypeReference>() { + }); + logger.debug("tenantId:" + tenantId); + logger.debug("type:" + type); + logger.debug("logList:" + logList); + Date currentDate = new Date(); + + StoreOperationLogService storeOperationLogService = dubboSupport.getStoreOperationLogService(); + storeOperationLogService.save(tenantId, logList); + logger.info("MQ消息(操作日志上传)处理完成--->[{},{},{}]", tenantId, type, currentDate); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } catch (Exception e) { + logger.error("MQ消息(操作日志上传)处理发生异常", e); + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } + } + + }); + return container; + } + + // 队列-操作日志上传 + @Bean(name = "queue4productsalestock") + public Queue queue4productsalestock() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_PRODUCT_SALE_STOCK).build(); + } + + @Bean(name = "messageContainer4productsalestock") + public SimpleMessageListenerContainer messageContainer4productsalestock() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + container.setQueues(this.queue4productsalestock()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(1); + container.setConcurrentConsumers(1); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.debug("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + + List orderProductList = JSONUtil.parseObject(JSONUtil.toJSONString(dataMap.get("orderProductList")), new TypeReference>() { + }); + logger.debug("tenantId:" + tenantId); + logger.debug("type:" + type); + logger.debug("orderProductList:" + orderProductList); + Date currentDate = new Date(); + + StoreProductSaleStockService storeProductSaleStockService = dubboSupport.getStoreProductSaleStockService(); + sortOrderProductBurden(orderProductList); + Map typeMap = new HashMap(); + String specId_temp = ""; + int i = 0; + double count = 0.00; + List> result = new ArrayList>(); + int listLength = orderProductList.size(); + for (StoreOrderProduct storeOrderProduct : orderProductList) { + String specId = storeOrderProduct.getSpecId(); + if (!specId_temp.equals(specId)) { + if (i != 0) { + typeMap.put("tenantId", storeOrderProduct.getTenantId()); + typeMap.put("storeId", storeOrderProduct.getStoreId()); + typeMap.put("specId", specId_temp); + typeMap.put("count", storeOrderProduct.getCount() - storeOrderProduct.getRcount()); + result.add(typeMap); + // 分类改变时,清除缓存 + typeMap = new HashMap(); + } + count = 0.00; + specId_temp = storeOrderProduct.getSpecId(); + } + count = count + (storeOrderProduct.getCount() - storeOrderProduct.getRcount()); + i = i + 1; + if (i == listLength) { + typeMap.put("tenantId", storeOrderProduct.getTenantId()); + typeMap.put("storeId", storeOrderProduct.getStoreId()); + typeMap.put("specId", specId_temp); + typeMap.put("count", count); + result.add(typeMap); + // 分类改变时,清除缓存 + typeMap = new HashMap(); + } + } + List list = new ArrayList(); + for (Map map : result) { + StoreOrderProduct entityProduct = new StoreOrderProduct(); + entityProduct.setTenantId(map.get("tenantId").toString()); + entityProduct.setStoreId(map.get("storeId").toString()); + entityProduct.setSpecId(map.get("specId").toString()); + entityProduct.setCount(Double.parseDouble(map.get("count").toString())); + list.add(entityProduct); + } + // 库存扣减项 + storeProductSaleStockService.updateStoreProductSaleStock(tenantId, list); + logger.info("MQ消息(商品库存扣减)处理完成--->[{},{},{}]", tenantId, type, currentDate); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } catch (Exception e) { + logger.error("MQ消息(商品库存扣减)处理发生异常", e); + } + } + + }); + return container; + } + + private void sortOrderProductBurden(List data) { + + Collections.sort(data, new Comparator() { + @Override + public int compare(StoreOrderProduct o1, StoreOrderProduct o2) { + String a = o1.getSpecId(); + String b = o2.getSpecId(); + // 升序 + return a.compareTo(b); + } + }); + } + + private void sortOrderProgramBurden(List data) { + + Collections.sort(data, new Comparator() { + @Override + public int compare(ProgramStoreOrderProduct o1, ProgramStoreOrderProduct o2) { + String a = o1.getSpecId(); + String b = o2.getSpecId(); + // 升序 + return a.compareTo(b); + } + }); + } + + public static String filter(String str) { + if (str.trim().isEmpty()) { + return str; + } + String pattern = "[\uD83C\uDC04-\uD83C\uDE1A]|[\uD83D\uDC66-\uD83D\uDC69]|[\uD83D\uDC66\uD83C\uDFFB-\uD83D\uDC69\uD83C\uDFFF]|[\uD83D\uDE45\uD83C\uDFFB-\uD83D\uDE4F\uD83C\uDFFF]|[\uD83C\uDC00-\uD83D\uDFFF]|[\uD83E\uDD10-\uD83E\uDDC0]|[\uD83D\uDE00-\uD83D\uDE4F]|[\uD83D\uDE80-\uD83D\uDEF6]|[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]"; + String reStr = ""; + Pattern emoji = Pattern.compile(pattern); + Matcher emojiMatcher = emoji.matcher(str); + str = emojiMatcher.replaceAll(reStr); + return str.replace("\\", ""); + } + + // 队列-小程序库存变更日志上传 + @Bean(name = "queue4programsalestock") + public Queue queue4programsalestock() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_PROGRAM_SALE_STOCK).build(); + } + + @Bean(name = "messageContainer4programsalestock") + public SimpleMessageListenerContainer messageContainer4programsalestock() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + container.setQueues(this.queue4programsalestock()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(1); + container.setConcurrentConsumers(1); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener() { + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try { + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.error("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + String tenantId = dataMap.get("tenantId").toString(); + String type = dataMap.get("type").toString(); + + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + + String storeId = dataMap.get("storeId").toString(); + String busNo = dataMap.get("busNo").toString(); + logger.error("tenantId:====>" + tenantId); + logger.error("type:====>" + type); + logger.error("storeId:====>" + storeId); + logger.error("busNo:====>" + busNo); + Date currentDate = new Date(); + + ProgramStoreOrderProductService programStoreOrderProductService = dubboSupport.getProgramStoreOrderProductService(); + StoreProductService storeProductService = dubboSupport.getStoreProductService(); + Criteria criteria = new Criteria(); + criteria.add(Restrictions.eq("tenantId", tenantId)); + criteria.add(Restrictions.eq("storeId", storeId)); + criteria.add(Restrictions.eq("busNo", busNo)); + List orderProductList = programStoreOrderProductService.getList(tenantId, criteria); + sortOrderProgramBurden(orderProductList); + Map typeMap = new HashMap(); + String specId_temp = ""; + int i = 0; + double count = 0.00; + List> result = new ArrayList>(); + int listLength = orderProductList.size(); + for (ProgramStoreOrderProduct storeOrderProduct : orderProductList) { + String specId = storeOrderProduct.getSpecId(); + if (!specId_temp.equals(specId)) { + if (i != 0) { + typeMap.put("tenantId", storeOrderProduct.getTenantId()); + typeMap.put("storeId", storeOrderProduct.getStoreId()); + typeMap.put("specId", specId_temp); + typeMap.put("count", storeOrderProduct.getCount() - storeOrderProduct.getRcount()); + result.add(typeMap); + // 分类改变时,清除缓存 + typeMap = new HashMap(); + } + count = 0.00; + specId_temp = storeOrderProduct.getSpecId(); + } + count = count + (storeOrderProduct.getCount() - storeOrderProduct.getRcount()); + i = i + 1; + if (i == listLength) { + typeMap.put("tenantId", storeOrderProduct.getTenantId()); + typeMap.put("storeId", storeOrderProduct.getStoreId()); + typeMap.put("specId", specId_temp); + typeMap.put("count", count); + result.add(typeMap); + // 分类改变时,清除缓存 + typeMap = new HashMap(); + } + } + List list = new ArrayList(); + for (Map map : result) { + ProgramStoreOrderProduct entityProduct = new ProgramStoreOrderProduct(); + entityProduct.setTenantId(map.get("tenantId").toString()); + entityProduct.setStoreId(map.get("storeId").toString()); + entityProduct.setSpecId(map.get("specId").toString()); + if ("refundagree".equals(type)) { + entityProduct.setCount(0 - Double.parseDouble(map.get("count").toString())); + } else if ("confirm".equals(type)) { + entityProduct.setCount(Double.parseDouble(map.get("count").toString())); + } + list.add(entityProduct); + } + // 库存扣减项 + storeProductService.updateStoreProductSaleStock(tenantId, list); + logger.info("MQ消息(小程序商品库存扣减)处理完成--->[{},{},{}]", tenantId, type, currentDate); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } catch (Exception e) { + logger.error("MQ消息(小程序商品库存扣减)处理发生异常", e); + } + } + + }); + return container; + } + + + /** + * 延迟队列 + */ + @Bean(name = "queue4businessorderplus4delay") + public Queue queue4businessorderplus4delay() { + logger.error("queue4businessorderplus4delay --------------------------->>>>>>>>>>>>>>> 已创建 "); + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_BUSINESS_ORDER_PLUS_DELAY) + .withArgument("x-dead-letter-exchange", RabbitConstant.EXCHANGE_NAME) + .withArgument("x-dead-letter-routing-key", RabbitConstant.ROUTING_KEY_BUSINESS_ORDER_PLUS) + .build(); + } + + @Bean(name = "binding4businessorderplus4delay") + public Binding binding4businessorderplus4delay() { + return BindingBuilder.bind(this.queue4businessorderplus4delay()).to(this.defaultExchange()).with(RabbitConstant.ROUTING_KEY_BUSINESS_ORDER_PLUS_DELAY); + } + + @Bean(name = "queue4jwprogramordernotify") + public Queue queue4jwprogramordernotify() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_JW_PROGRAM_ORDER_NOTIFY).build(); + } + + + @Bean(name = "messageContainer4jwprogramordernotify") + public SimpleMessageListenerContainer messageContainer4jwprogramordernotify() { + SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory()); + container.setQueues(this.queue4jwprogramordernotify()); // 设置要监听的队列 + container.setExposeListenerChannel(true); + container.setMaxConcurrentConsumers(3); + container.setConcurrentConsumers(1); + container.setAcknowledgeMode(AcknowledgeMode.MANUAL); // 设置确认模式手工确认 + container.setMessageListener(new ChannelAwareMessageListener(){ + + @Override + public void onMessage(Message message, Channel channel) throws Exception { + try{ + byte[] body = message.getBody(); + String bodyContent = new String(body); + logger.error("receive msg : " + bodyContent); + Map dataMap = JSONUtil.parseObject(bodyContent, new TypeReference>() { + }); + logger.debug("dataMap: " + JSONUtil.toJSONString(dataMap)); + + CacheService cacheService = dubboSupport.getCacheService(); + + String tenantId = dataMap.get("tenantId").toString(); + String storeId = dataMap.get("storeId").toString(); + String orderNo = dataMap.get("orderNo").toString(); + + //2023-04-14 定制租户号直接返回确认 + if(DISABLED_BODUO_TENANTID_STRS.contains(tenantId)){ + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + return ; + } + + Integer reSendNums = dataMap.get("reSendNums") == null ? 0:(Integer)dataMap.get("reSendNums"); + Object programOrderIds = cacheService.get(tenantId, "program_" + storeId); + if (programOrderIds != null) { + Map orderIds = (Map) cacheService.get(tenantId, "program_" + storeId); + if(orderIds.containsKey(orderNo)){ + if(reSendNums < 5){ + reSendNums = reSendNums + 1; + String ids = ""; + for (Map.Entry entry : orderIds.entrySet()) { + ids = ids + entry.getKey() + ","; + } + if (ids.length() > 0) { + ids = ids.substring(0, ids.length() - 1); + } + if (ids != null && !"".equals(ids)) { + DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Map order = new HashMap<>(); + order.put("program", ids); + order.put("date", fmt.format(new Date())); + mqttClient.Publish("program/cy2/" + tenantId + "/" + storeId, JSONUtil.toJSONString(order)); + logger.error( " mqtt 推送信息 ," + tenantId + "/" + storeId+"/order:{}", JSONUtil.toJSONString(order)); + } else { + logger.error( "mqtt 推送信息,"+tenantId+","+storeId+","+orderNo+",未发布"); + } + Map orderMap = new HashMap<>(); + orderMap.put("tenantId",tenantId); + orderMap.put("storeId",storeId); + orderMap.put("orderNo",orderNo); + orderMap.put("reSendNums",reSendNums); + mqMessageSender.send4jwprogramordermessage(tenantId,orderMap,new CorrelationData(UUID.randomUUID().toString()),1000L*90); + } + } + } + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + }catch (Exception e){ + logger.error("MQ消息(巨为小程序订单推送)处理发生异常", e); + // 确认消息成功消费 + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } + } + }); + return container; + } + + + /** + * 延迟队列 + */ + @Bean(name = "queue4jwprogramorder4delay") + public Queue queue4jwprogramorder4delay() { + return QueueBuilder.durable(RabbitConstant.QUEUE_NAME_JW_PROGRAM_ORDER_DELAY) + .withArgument("x-dead-letter-exchange", RabbitConstant.EXCHANGE_NAME) + .withArgument("x-dead-letter-routing-key", RabbitConstant.ROUTING_KEY_JW_PROGRAM_ORDER_NOTIFY) + .build(); + } + + @Bean(name = "binding4jwprogramorder4delay") + public Binding binding4jwprogramorder4delay() { + return BindingBuilder.bind(this.queue4jwprogramorder4delay()).to(this.defaultExchange()).with(RabbitConstant.ROUTING_KEY_JW_PROGRAM_ORDER_NOTIFY_DELAY); + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/mqtt/MqttClientExt.java b/food-mq/src/main/java/com/jwsaas/mqtt/MqttClientExt.java new file mode 100644 index 0000000..d879e7a --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/mqtt/MqttClientExt.java @@ -0,0 +1,308 @@ +package com.jwsaas.mqtt; + +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +//// @Resource private MqttClientExt mqttClient; +// mqttClient.Publisher(); + +public class MqttClientExt { + + private static Logger logger = LoggerFactory.getLogger(MqttClientExt.class); + + private final int QOS = 2; + + private ScheduledExecutorService scheduler; + + private MqttClient mqttClient; + + private MqttConnectOptions options; + + private String clientId; + + private String host; + + private Integer port; + + private Integer keepAlive; + + private Integer connectionTimeout; + + private String userName = "00000"; + + private String passwd = "0000000000000000000"; + + private Queue> wait = null; + + public MqttClientExt() { + wait = new ConcurrentLinkedQueue>(); + } + + + private void connect() { + try { + + logger.info("初始化MQTT消息服务......"); + + String serverURI = "tcp://" + this.getHost() + ":" + this.getPort(); + + MemoryPersistence persistence = new MemoryPersistence(); + + this.mqttClient = new MqttClient(serverURI, this.getClientId(), persistence); + + // MQTT的连接设置 + this.options = new MqttConnectOptions(); + + //设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接 + //如果是true,那么清理所有离线消息,即QoS1或者2的所有未接收内容 + this.options.setCleanSession(false); + + this.options.setMaxInflight(10000); + + // 设置超时时间 单位为秒 + this.options.setConnectionTimeout(this.getConnectionTimeout()); + // 设置会话心跳时间 单位为秒 服务器会每隔20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制 + this.options.setKeepAliveInterval(this.getKeepAlive()); + + this.options.setUserName(this.getUserName()); + + this.options.setPassword(this.getPasswd().toCharArray()); + //设置是否自动重连 + this.options.setAutomaticReconnect(false);// this.options.setAutomaticReconnect(true); + // 设置回调 + mqttClient.setCallback(new PushCallback()); + + mqttClient.connect(options); + + } catch (Exception ex) { + + mqttClient = null; + + logger.error("连接MQTT消息中心异常",ex); + } + } + + public void init() { + + try { + + this.connect(); + + } catch (Exception ex) { + logger.error("连接MQTT消息中心异常",ex); + } + finally { + logger.info("连接MQTT消息中心状态:" + this.isConnected()); + + scheduler = Executors.newSingleThreadScheduledExecutor(); + scheduler.scheduleAtFixedRate(new Runnable() { + public void run() { + try { + logger.info("MQTT消息中心状态<{}>,消息队列<{}>",isConnected(),wait.size()); + + if(!isConnected()) { + + logger.info("重新连接MQTT消息中心......"); + + connect(); + } + + if(!wait.isEmpty()) { + //循环次数 + int loop = wait.size() > 100 ? 100 : wait.size(); + + for(int i = 0;i data = wait.poll(); + + Date date = (Date) data.get("date"); + Integer count = (Integer) data.get("count"); + + long currDate = new Date().getTime(); + //发送超过10次或超过5分钟丢弃 + if(count > 10 || currDate - date.getTime() > 5*60*60*1000) { + return; + } + + if(isConnected()) { + + String topic = data.get("topic").toString(); + String payload = data.get("payload").toString(); + + Publish(topic,payload); + } + else { + data.put("date", new Date()); + + count++; + data.put("count", count); + + wait.add(data); + } + + Thread.sleep(10); + } + } + + } catch (Exception e) { + logger.error("检测MQTT消息中心状态异常",e); + } + } + }, 20 * 1000, 30 * 1000, TimeUnit.MILLISECONDS); + } + } + + public void destroy() { + try { + + if(this.isConnected()) { + + this.mqttClient.disconnect(); + + logger.info("断开MQTT消息中心连接"); + } + + this.mqttClient = null; + + } catch (MqttException ex) { + logger.error("断开MQTT消息中心连接异常",ex); + } + } + + public boolean isConnected() { + return this.mqttClient != null && this.mqttClient.isConnected(); + } + + public void Publish(String topic, String payload,Integer count) { + + try { + if(this.isConnected()) { + + MqttMessage message = new MqttMessage(payload.getBytes()); + + message.setQos(this.QOS); + + mqttClient.publish(topic, message); + + logger.debug("<{}>进行第<{}>次发布...",topic,count); + } + else + { + Map data = new HashMap(); + data.put("topic", topic); + data.put("payload", payload); + + data.put("date", new Date()); + count++; + data.put("count", count); + + this.wait.add(data); + } + }catch (Exception ex) { + logger.error("MQTT发布消息异常",ex); + } + + + } + + public void Publish(String topic, String payload) { + Publish(topic, payload,1); + } + + + public void Subscribe(String topicFilter) throws MqttException { + + try { + if(this.isConnected()) { + mqttClient.subscribe(topicFilter, this.QOS); + } + }catch (Exception ex) { + logger.error("MQTT订阅异常",ex); + } + } + + public void Unsubscribe(String topicFilter) throws MqttException { + + try { + if(this.isConnected()) { + mqttClient.unsubscribe(topicFilter); + } + }catch (Exception ex) { + logger.error("MQTT退订异常",ex); + } + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public Integer getKeepAlive() { + return keepAlive; + } + + public void setKeepAlive(Integer keepAlive) { + this.keepAlive = keepAlive; + } + + public Integer getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(Integer connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPasswd() { + return passwd; + } + + public void setPasswd(String passwd) { + this.passwd = passwd; + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/mqtt/MqttConfiguration.java b/food-mq/src/main/java/com/jwsaas/mqtt/MqttConfiguration.java new file mode 100644 index 0000000..6284976 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/mqtt/MqttConfiguration.java @@ -0,0 +1,48 @@ +package com.jwsaas.mqtt; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MqttConfiguration { + + @Value("${mqtt.clientId:clientId}") + private String clientId; + + @Value("${mqtt.host:0.0.0.0}") + private String mqttHost; + + @Value("${mqtt.port:1883}") + private Integer mqttPort; + + @Value("${mqtt.keepalive:60}") + private int keepAlive; + + @Value("${mqtt.connection.timeout:10}") + private Integer connectionTimeout; + + @Value("${mqtt.username:admin}") + private String userName; + + @Value("${mqtt.passwd:admin}") + private String passwd; + + @Bean(initMethod = "init") + public MqttClientExt mqttClient() { + + MqttClientExt mqttClient = new MqttClientExt(); + + mqttClient.setClientId(clientId); + + mqttClient.setHost(mqttHost); + mqttClient.setPort(mqttPort); + mqttClient.setKeepAlive(keepAlive); + mqttClient.setConnectionTimeout(connectionTimeout); + mqttClient.setUserName(userName); + mqttClient.setPasswd(passwd); + + return mqttClient; + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/mqtt/PushCallback.java b/food-mq/src/main/java/com/jwsaas/mqtt/PushCallback.java new file mode 100644 index 0000000..5955705 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/mqtt/PushCallback.java @@ -0,0 +1,32 @@ +package com.jwsaas.mqtt; + +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PushCallback implements MqttCallback { + + private static Logger logger = LoggerFactory.getLogger(PushCallback.class); + + @Override + public void connectionLost(Throwable cause) { + logger.error("连接失败,原因", cause); + } + + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + // subscribe后得到的消息会执行到这里面 + logger.debug("接收消息主题:" + topic); + logger.debug("接收消息Qos:" + message.getQos()); + logger.debug("接收消息内容:" + new String(message.getPayload())); + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + // publish后会执行到这里 + logger.debug("消息发送成功!" + ((token == null || token.getResponse() == null) ? "null" : token.getResponse().getKey())); + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/mqtt/Topic.java b/food-mq/src/main/java/com/jwsaas/mqtt/Topic.java new file mode 100644 index 0000000..fc84f1d --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/mqtt/Topic.java @@ -0,0 +1,74 @@ +package com.jwsaas.mqtt; + +import java.util.Map; + +public class Topic { + + public static String cardPayMsg = "%s:%s:pay"; + + private String topicName; // 主题名称 + + private String tenantId; // 企业编号 + + private String shopNo; // 门店编号 + + private String posNo; // pos编号 + + private String workerNo; // 员工编号 + + private Map ext; // 附加信息 + + public String getTopicName() { + return topicName; + } + + public void setTopicName(String topicName) { + this.topicName = topicName; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getShopNo() { + return shopNo; + } + + public void setShopNo(String shopNo) { + this.shopNo = shopNo; + } + + public String getPosNo() { + return posNo; + } + + public void setPosNo(String posNo) { + this.posNo = posNo; + } + + public String getWorkerNo() { + return workerNo; + } + + public void setWorkerNo(String workerNo) { + this.workerNo = workerNo; + } + + public Map getExt() { + return ext; + } + + public void setExt(Map ext) { + this.ext = ext; + } + + @Override + public String toString() { + return "Topic [topicName=" + topicName + ", shopNo=" + shopNo + ", posNo=" + posNo + ", workerNo=" + workerNo + ", ext=" + ext + "]"; + } + +} diff --git a/food-mq/src/main/java/com/jwsaas/util/JSONException.java b/food-mq/src/main/java/com/jwsaas/util/JSONException.java new file mode 100644 index 0000000..eba254b --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/util/JSONException.java @@ -0,0 +1,18 @@ +package com.jwsaas.util; + +@SuppressWarnings("serial") +public class JSONException extends RuntimeException { + + public JSONException(){ + super(); + } + + public JSONException(String message){ + super(message); + } + + public JSONException(String message, Throwable cause){ + super(message, cause); + } + +} \ No newline at end of file diff --git a/food-mq/src/main/java/com/jwsaas/util/JSONUtil.java b/food-mq/src/main/java/com/jwsaas/util/JSONUtil.java new file mode 100644 index 0000000..78c79b2 --- /dev/null +++ b/food-mq/src/main/java/com/jwsaas/util/JSONUtil.java @@ -0,0 +1,167 @@ +package com.jwsaas.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonEncoding; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class JSONUtil { + + protected static Logger logger = LoggerFactory.getLogger(JSONUtil.class); + + private static ObjectMapper objectMapper = new ObjectMapper(); + private static final String charsetName = "UTF-8"; + + static { + objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); + serializationConfig = serializationConfig.without(SerializationFeature.WRAP_ROOT_VALUE) + .with(SerializationFeature.INDENT_OUTPUT); + SerializerProvider serializerProvider = objectMapper.getSerializerProvider(); + serializerProvider.setNullValueSerializer(new JsonSerializer() { + + @Override + public void serialize(Object value, JsonGenerator jgen, SerializerProvider serializers) + throws IOException, JsonProcessingException { + jgen.writeString(""); + } + + }); + } + +// public static ObjectMapper getObjectMapper() { +// return CollectionUtils.deepCopy(objectMapper); +// } + + public static String toJSONString(Object object) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); + try { + JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(bos, JsonEncoding.UTF8); + objectMapper.writeValue(jsonGenerator, object); + return bos.toString(charsetName); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } finally { + try { + bos.close(); + } catch (Exception ex) { + logger.error("toJSONString(bos.close) Exception ", ex); + } + } + } + + public static JsonNode parseJsonNode(String text) { + try { + return objectMapper.readTree(text); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } + } + + public static T parseObject(String text, Class clazz) { + try { + return objectMapper.readValue(text, clazz); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } + } + + public static T parseObject(String text, Class clazz, String charsetName) { + try { + return objectMapper.readValue(text.getBytes(charsetName), clazz); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } + } + + public static T parseObject(String text, TypeReference valueTypeRef) { + try { + return objectMapper.readValue(objectMapper.getFactory().createParser(text), valueTypeRef); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } + } + + public static ObjectNode createObjectNode() { + try { + return objectMapper.createObjectNode(); + } catch (Exception e) { + throw new JSONException(e.getMessage(), e); + } + } + + /** + * 从json中读取tagPath处的值 tagPath用 :分隔 + * + * @param json + * @param tagPath + * @return + * @throws Exception + */ + public static List readValueFromJson(String json, String tagPath) throws Exception { + // 返回值 + List value = new ArrayList(); + if (StringUtils.isBlank(json) || StringUtils.isBlank(tagPath)) { + return value; + } + String[] path = tagPath.split(":"); + JsonNode node = objectMapper.readTree(json); + getJsonValue(node, path, value, 1); + return value; + } + + public static void getJsonValue(JsonNode node, String[] path, List values, int nextIndex) { + if (node == null) { + return; + } + // 是路径的最后就直接取值 + if (nextIndex == path.length) { + if (node.isArray()) { + for (int i = 0; i < node.size(); i++) { + JsonNode child = node.get(i).get(path[nextIndex - 1]); + if (child == null) { + continue; + } + values.add(child.toString()); + } + } else { + JsonNode child = node.get(path[nextIndex - 1]); + if (child != null) { + values.add(child.toString()); + } + } + return; + } + // 判断是Node下是集合还是一个节点 + node = node.get(path[nextIndex - 1]); + if (node.isArray()) { + for (int i = 0; i < node.size(); i++) { + getJsonValue(node.get(i), path, values, nextIndex + 1); + } + } else { + getJsonValue(node, path, values, nextIndex + 1); + } + } + +} diff --git a/food-mq/src/main/lib/libwrapper-macosx-universal-32.jnilib b/food-mq/src/main/lib/libwrapper-macosx-universal-32.jnilib new file mode 100644 index 0000000..ae75d31 Binary files /dev/null and b/food-mq/src/main/lib/libwrapper-macosx-universal-32.jnilib differ diff --git a/food-mq/src/main/lib/libwrapper-macosx-universal-64.jnilib b/food-mq/src/main/lib/libwrapper-macosx-universal-64.jnilib new file mode 100644 index 0000000..e7d4102 Binary files /dev/null and b/food-mq/src/main/lib/libwrapper-macosx-universal-64.jnilib differ diff --git a/food-mq/src/main/lib/wrapper-windows-x86-32.dll b/food-mq/src/main/lib/wrapper-windows-x86-32.dll new file mode 100644 index 0000000..6aaa9c1 Binary files /dev/null and b/food-mq/src/main/lib/wrapper-windows-x86-32.dll differ diff --git a/food-mq/src/main/lib/wrapper-windows-x86-64.dll b/food-mq/src/main/lib/wrapper-windows-x86-64.dll new file mode 100644 index 0000000..81f11ce Binary files /dev/null and b/food-mq/src/main/lib/wrapper-windows-x86-64.dll differ diff --git a/food-mq/src/main/lib/wrapper.jar b/food-mq/src/main/lib/wrapper.jar new file mode 100644 index 0000000..70dc5ab Binary files /dev/null and b/food-mq/src/main/lib/wrapper.jar differ diff --git a/food-mq/src/main/resources/application.properties b/food-mq/src/main/resources/application.properties new file mode 100644 index 0000000..b48ea7d --- /dev/null +++ b/food-mq/src/main/resources/application.properties @@ -0,0 +1,49 @@ +#application +application.name=food-mq +application.owner= + +#RabbitMQ +spring.rabbitmq.host=127.0.0.1 +spring.rabbitmq.port=5672 +spring.rabbitmq.virtualHost=/dev_test +spring.rabbitmq.publisherConfirms=true +spring.rabbitmq.username=guest +spring.rabbitmq.password=guest + +# Dubbo service version +food.service.group=default +food.service.version=2.0.0 + +# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service +dubbo.scan.basePackages=com.jwsaas + +# Dubbo Config properties +## ApplicationConfig Bean +dubbo.application.id=food-mq +dubbo.application.name=food-mq +dubbo.application.qos-enable=false +dubbo.application.qos-port=22222 + +## ConsumerConfig Bean +dubbo.consumer.id=dubbo +dubbo.consumer.name=dubbo +dubbo.consumer.client=netty4 + +## RegistryConfig Bean +dubbo.registry.id=food-registry +dubbo.registry.address=zookeeper://127.0.0.1:2181 +dubbo.registry.client=curator +dubbo.registry.file=/home/project/foodv2/dubbo/food-mq.cache + +## consume +dubbo.consumer.timeout=600000 +# \u670D\u52A1\u542F\u52A8\u65F6\u68C0\u67E5\u88AB\u8C03\u7528\u670D\u52A1\u662F\u5426\u53EF\u7528 +dubbo.consumer.check=true +dubbo.consumer.retries=0 + +#MQTT +mqtt.clientId=cy2_foodmq_kaifa_01 +mqtt.host=iotv2.ffcygl.com +mqtt.port=18830 +mqtt.keepalive=60 +mqtt.connection.timeout=10 diff --git a/food-mq/src/main/resources/logback.xml b/food-mq/src/main/resources/logback.xml new file mode 100644 index 0000000..be9e3e2 --- /dev/null +++ b/food-mq/src/main/resources/logback.xml @@ -0,0 +1,24 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] %logger{120} - %msg %n + + + + + + + + + + + + + + + + + diff --git a/food-mq/target/classes/application.properties b/food-mq/target/classes/application.properties new file mode 100644 index 0000000..b48ea7d --- /dev/null +++ b/food-mq/target/classes/application.properties @@ -0,0 +1,49 @@ +#application +application.name=food-mq +application.owner= + +#RabbitMQ +spring.rabbitmq.host=127.0.0.1 +spring.rabbitmq.port=5672 +spring.rabbitmq.virtualHost=/dev_test +spring.rabbitmq.publisherConfirms=true +spring.rabbitmq.username=guest +spring.rabbitmq.password=guest + +# Dubbo service version +food.service.group=default +food.service.version=2.0.0 + +# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service +dubbo.scan.basePackages=com.jwsaas + +# Dubbo Config properties +## ApplicationConfig Bean +dubbo.application.id=food-mq +dubbo.application.name=food-mq +dubbo.application.qos-enable=false +dubbo.application.qos-port=22222 + +## ConsumerConfig Bean +dubbo.consumer.id=dubbo +dubbo.consumer.name=dubbo +dubbo.consumer.client=netty4 + +## RegistryConfig Bean +dubbo.registry.id=food-registry +dubbo.registry.address=zookeeper://127.0.0.1:2181 +dubbo.registry.client=curator +dubbo.registry.file=/home/project/foodv2/dubbo/food-mq.cache + +## consume +dubbo.consumer.timeout=600000 +# \u670D\u52A1\u542F\u52A8\u65F6\u68C0\u67E5\u88AB\u8C03\u7528\u670D\u52A1\u662F\u5426\u53EF\u7528 +dubbo.consumer.check=true +dubbo.consumer.retries=0 + +#MQTT +mqtt.clientId=cy2_foodmq_kaifa_01 +mqtt.host=iotv2.ffcygl.com +mqtt.port=18830 +mqtt.keepalive=60 +mqtt.connection.timeout=10 diff --git a/food-mq/target/classes/com/jwsaas/Application.class b/food-mq/target/classes/com/jwsaas/Application.class new file mode 100644 index 0000000..fc157cd Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/Application.class differ diff --git a/food-mq/target/classes/com/jwsaas/Constant.class b/food-mq/target/classes/com/jwsaas/Constant.class new file mode 100644 index 0000000..5fa4053 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/Constant.class differ diff --git a/food-mq/target/classes/com/jwsaas/RabbitConstant.class b/food-mq/target/classes/com/jwsaas/RabbitConstant.class new file mode 100644 index 0000000..49329a3 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/RabbitConstant.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/DubboSupport.class b/food-mq/target/classes/com/jwsaas/config/DubboSupport.class new file mode 100644 index 0000000..028d93c Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/DubboSupport.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/ExpirationMessagePostProcessor.class b/food-mq/target/classes/com/jwsaas/config/ExpirationMessagePostProcessor.class new file mode 100644 index 0000000..826d62e Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/ExpirationMessagePostProcessor.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/MQMessageSender.class b/food-mq/target/classes/com/jwsaas/config/MQMessageSender.class new file mode 100644 index 0000000..8934769 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/MQMessageSender.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$1.class new file mode 100644 index 0000000..1fef19d Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$2.class new file mode 100644 index 0000000..e4c6ca0 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1.class new file mode 100644 index 0000000..8777981 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$1.class new file mode 100644 index 0000000..27da81c Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$2.class new file mode 100644 index 0000000..d9516bd Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2.class new file mode 100644 index 0000000..d851acf Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$1.class new file mode 100644 index 0000000..9b3860e Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$2.class new file mode 100644 index 0000000..af22d83 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$3.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$3.class new file mode 100644 index 0000000..73c4f31 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$3.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$4.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$4.class new file mode 100644 index 0000000..358cda3 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$4.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$5.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$5.class new file mode 100644 index 0000000..5e1fd82 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$5.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$6.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$6.class new file mode 100644 index 0000000..4ec62cf Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$6.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$7.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$7.class new file mode 100644 index 0000000..3eefbb7 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$7.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$8.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$8.class new file mode 100644 index 0000000..96ffc87 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$8.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$9.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$9.class new file mode 100644 index 0000000..938c026 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3$9.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3.class new file mode 100644 index 0000000..38e682b Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$3.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$1.class new file mode 100644 index 0000000..988b02b Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$2.class new file mode 100644 index 0000000..ae3221b Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4.class new file mode 100644 index 0000000..30ed2df Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$4.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$1.class new file mode 100644 index 0000000..fd955c9 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$2.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$2.class new file mode 100644 index 0000000..a679d01 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5$2.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5.class new file mode 100644 index 0000000..61fa193 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$5.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$6.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$6.class new file mode 100644 index 0000000..e6d375e Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$6.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$7.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$7.class new file mode 100644 index 0000000..bd2a916 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$7.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8$1.class new file mode 100644 index 0000000..a4a2ecd Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8.class new file mode 100644 index 0000000..ca19d49 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$8.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9$1.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9$1.class new file mode 100644 index 0000000..fdc38fb Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9.class new file mode 100644 index 0000000..2e1027e Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig$9.class differ diff --git a/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig.class b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig.class new file mode 100644 index 0000000..69bff1e Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/config/RabbitMQConfig.class differ diff --git a/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt$1.class b/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt$1.class new file mode 100644 index 0000000..a087bba Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt.class b/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt.class new file mode 100644 index 0000000..2e3f435 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/mqtt/MqttClientExt.class differ diff --git a/food-mq/target/classes/com/jwsaas/mqtt/MqttConfiguration.class b/food-mq/target/classes/com/jwsaas/mqtt/MqttConfiguration.class new file mode 100644 index 0000000..80a4654 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/mqtt/MqttConfiguration.class differ diff --git a/food-mq/target/classes/com/jwsaas/mqtt/PushCallback.class b/food-mq/target/classes/com/jwsaas/mqtt/PushCallback.class new file mode 100644 index 0000000..c9035e5 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/mqtt/PushCallback.class differ diff --git a/food-mq/target/classes/com/jwsaas/mqtt/Topic.class b/food-mq/target/classes/com/jwsaas/mqtt/Topic.class new file mode 100644 index 0000000..daece52 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/mqtt/Topic.class differ diff --git a/food-mq/target/classes/com/jwsaas/util/JSONException.class b/food-mq/target/classes/com/jwsaas/util/JSONException.class new file mode 100644 index 0000000..8b7b8e1 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/util/JSONException.class differ diff --git a/food-mq/target/classes/com/jwsaas/util/JSONUtil$1.class b/food-mq/target/classes/com/jwsaas/util/JSONUtil$1.class new file mode 100644 index 0000000..1f2fd66 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/util/JSONUtil$1.class differ diff --git a/food-mq/target/classes/com/jwsaas/util/JSONUtil.class b/food-mq/target/classes/com/jwsaas/util/JSONUtil.class new file mode 100644 index 0000000..a68f571 Binary files /dev/null and b/food-mq/target/classes/com/jwsaas/util/JSONUtil.class differ diff --git a/food-mq/target/classes/logback.xml b/food-mq/target/classes/logback.xml new file mode 100644 index 0000000..be9e3e2 --- /dev/null +++ b/food-mq/target/classes/logback.xml @@ -0,0 +1,24 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] %logger{120} - %msg %n + + + + + + + + + + + + + + + + + diff --git a/food-mq/target/food-mq-2.0.0.jar b/food-mq/target/food-mq-2.0.0.jar new file mode 100644 index 0000000..9e7b08e Binary files /dev/null and b/food-mq/target/food-mq-2.0.0.jar differ diff --git a/food-mq/target/food-mq-2.0.0.jar.original b/food-mq/target/food-mq-2.0.0.jar.original new file mode 100644 index 0000000..13a159d Binary files /dev/null and b/food-mq/target/food-mq-2.0.0.jar.original differ diff --git a/food-mq/target/food-mq-2.0.0.zip b/food-mq/target/food-mq-2.0.0.zip new file mode 100644 index 0000000..ed9f797 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0.zip differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/install.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/install.bat new file mode 100644 index 0000000..046a68c --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/install.bat @@ -0,0 +1,140 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM +rem as is. +rem If _WRAPPER_CONF_OVERRIDE is specified then all parameters will be passed. +rem If not set then all parameters starting with the second will be passed. +set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/middleware b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/middleware new file mode 100644 index 0000000..ff3ebd0 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/middleware @@ -0,0 +1,2162 @@ +#! /bin/sh + +# +# Copyright (c) 1999, 2016 Tanuki Software, Ltd. +# http://www.tanukisoftware.com +# All rights reserved. +# +# This software is the proprietary information of Tanuki Software. +# You shall use it only in accordance with the terms of the +# license agreement you entered into with Tanuki Software. +# http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +# +# Java Service Wrapper sh script. Suitable for starting and stopping +# wrapped Java applications on UNIX platforms. +# + +#----------------------------------------------------------------------------- +# These settings can be modified to fit the needs of your application +# Optimized for use with version 3.5.28 of the Wrapper. + +#******************************************************************** +# NOTE - This script has been modified to run the TestWrapper sample +# application and should NOT be used as a base for your own +# applications. All of the documentation assumes that you are +# working from the default source script: +# WRAPPER_HOME/src/bin/sh.script.in +#******************************************************************** + +# IMPORTANT - Please always stop and uninstall an application before making +# any changes to this file. Failure to do so could remove the +# script's ability to control the application. + +# Initialization block for the install_initd and remove_initd scripts used by +# SUSE linux, CentOS and RHEL distributions. +# Note: From CentOS 6, make sure the BEGIN INIT INFO section is before any line +# of code otherwise the service won't be displayed in the Service +# Configuration GUI. +### BEGIN INIT INFO +# Provides: wrapper +# Required-Start: $local_fs $network $syslog +# Should-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Wrapper Sample Application +# Description: Wrapper Sample Application Description +### END INIT INFO + +# Application +APP_NAME="food_mq" +APP_LONG_NAME="food mq application" + +# If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer +# be passed to the wrapper. See documentation for details. +#APP_NAME_PASS_TO_WRAPPER=false + +# Wrapper +WRAPPER_CMD="./wrapper" +WRAPPER_CONF="../conf/wrapper.conf" + +# Priority at which to run the wrapper. See "man nice" for valid priorities. +# nice is only used if a priority is specified. +PRIORITY= + +# Location of the pid file. +PIDDIR="." + +# PIDFILE_CHECK_PID tells the script to double check whether the pid in the pid +# file actually exists and belongs to this application. When not set, only +# check the pid, but not what it is. This is only needed when multiple +# applications need to share the same pid file. +PIDFILE_CHECK_PID=true + +# FIXED_COMMAND tells the script to use a hard coded action rather than +# expecting the first parameter of the command line to be the command. +# By default the command will will be expected to be the first parameter. +#FIXED_COMMAND=console + +# PASS_THROUGH tells the script to pass all arguments through to the JVM +# as is. If FIXED_COMMAND is specified then all arguments will be passed. +# If not set then all arguments starting with the second will be passed. +PASS_THROUGH=true + +# If uncommented, causes the Wrapper to be shutdown using an anchor file. +# When launched with the 'start' command, it will also ignore all INT and +# TERM signals. +#IGNORE_SIGNALS=true + +# Wrapper will start the JVM asynchronously. Your application may have some +# initialization tasks and it may be desirable to wait a few seconds +# before returning. For example, to delay the invocation of following +# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will +# cause the start command to delay for the indicated period of time +# (in seconds). +# +WAIT_AFTER_STARTUP=0 + +# If set, wait for the wrapper to report that the daemon has started +WAIT_FOR_STARTED_STATUS=true +WAIT_FOR_STARTED_TIMEOUT=120 + +# If set, the status, start_msg and stop_msg commands will print out detailed +# state information on the Wrapper and Java processes. +#DETAIL_STATUS=true + +# If set, the 'pause' and 'resume' commands will be enabled. These make it +# possible to pause the JVM or Java application without completely stopping +# the Wrapper. See the wrapper.pausable and wrapper.pausable.stop_jvm +# properties for more information. +#PAUSABLE=true + +# If specified, the Wrapper will be run as the specified user. +# IMPORTANT - Make sure that the user has the required privileges to write +# the PID file and wrapper.log files. Failure to be able to write the log +# file will cause the Wrapper to exit without any way to write out an error +# message. +# NOTE - This will set the user which is used to run the Wrapper as well as +# the JVM and is not useful in situations where a privileged resource or +# port needs to be allocated prior to the user being changed. +#RUN_AS_USER= + +# Set the full path to the 'su' command (substitute user). +# NOTE - In case 'su' is not in the PATH, you can set the absolute path here, +# for example: +# SU_BIN=/bin/su +# NOTE - For Red Hat, the script will use '/sbin/runuser' if it is present and +# ignore the value of SU_BIN. +SU_BIN=su + +# Set option for 'su'. +# In case the user set in RUN_AS_USER has no bash set, the 'su' command will fail. +# The workaround for GNU/Linux system is to specify which bash to use with +# the '-s' option. +#SU_OPTS="-s /bin/bash" + +# Set the full path to the 'id' command. +# For example: +# ID_BIN=/usr/bin/id +ID_BIN=id + +# By default we show a detailed usage block. Uncomment to show brief usage. +#BRIEF_USAGE=true + +# OS service management tool: flag for using Upstart when installing (rather than init.d rc.d) +USE_UPSTART= + +# OS service management tool: flag for using systemd when installing +USE_SYSTEMD= + +# When installing on Mac OSX platforms, the following domain will be used to +# prefix the plist file name. +PLIST_DOMAIN=org.tanukisoftware.wrapper + +# When installing on Mac OSX platforms, this parameter controls whether the daemon +# is to be kept continuously running or to let demand and conditions control the +# invocation. +MACOSX_KEEP_RUNNING="false" + +# The following two lines are used by the chkconfig command. Change as is +# appropriate for your application. They should remain commented. +# chkconfig: 2345 20 80 +# description: Test Wrapper Sample Application + +# Set run level to use when installing the application to start and stop on +# system startup and shutdown. It is important that the application always +# be uninstalled before making any changes to the run levels. +# It is also possible to specify different run levels based on the individual +# platform. When doing so this script will look for defined run levels in +# the following order: +# 1) "RUN_LEVEL_S_$DIST_OS" or "RUN_LEVEL_K_$DIST_OS", where "$DIST_OS" is +# the value of DIST_OS. "RUN_LEVEL_S_solaris=20" for example. +# 2) RUN_LEVEL_S or RUN_LEVEL_K, to specify specify start or stop run levels. +# 3) RUN_LEVEL, to specify a general run level. +RUN_LEVEL=20 + +# Do not modify anything beyond this point +#----------------------------------------------------------------------------- + +# check if we are running under Cygwin terminal. +# Note: on some OS's (for example Solaris, MacOS), -o is not a valid parameter +# and it shows an error message. We redirect stderr to null so the error message +# doesn't show up. +CYGWIN=`uname -o 2>/dev/null` +if [ "$CYGWIN" = "Cygwin" ] +then + eval echo `gettext 'This script is not compatible with Cygwin. Please use the Wrapper batch files to control the Wrapper.'` + exit 1 +fi + +if [ -n "$FIXED_COMMAND" ] +then + COMMAND="$FIXED_COMMAND" +else + COMMAND="$1" +fi + +# check if there is a parameter "sysd" +SYSD= +if [ $# -gt 1 ] ; then + if [ $2 = "sysd" ] ; then + SYSD=1 + fi +fi + +# default location for the service file +SYSTEMD_SERVICE_FILE="/etc/systemd/system/$APP_NAME.service" + +# Required for HP-UX Startup +if [ `uname -s` = "HP-UX" -o `uname -s` = "HP-UX64" ] ; then + PATH=$PATH:/usr/bin +fi + +# Get the fully qualified path to the script +case $0 in + /*) + SCRIPT="$0" + ;; + *) + PWD=`pwd` + SCRIPT="$PWD/$0" + ;; +esac + +# Resolve the true real path without any sym links. +CHANGED=true +while [ "X$CHANGED" != "X" ] +do + # Change spaces to ":" so the tokens can be parsed. + SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'` + # Get the real path to this script, resolving any symbolic links + TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'` + REALPATH= + for C in $TOKENS; do + # Change any ":" in the token back to a space. + C=`echo $C | sed -e 's;:; ;g'` + REALPATH="$REALPATH/$C" + # If REALPATH is a sym link, resolve it. Loop for nested links. + while [ -h "$REALPATH" ] ; do + LS="`ls -ld "$REALPATH"`" + LINK="`expr "$LS" : '.*-> \(.*\)$'`" + if expr "$LINK" : '/.*' > /dev/null; then + # LINK is absolute. + REALPATH="$LINK" + else + # LINK is relative. + REALPATH="`dirname "$REALPATH"`""/$LINK" + fi + done + done + + if [ "$REALPATH" = "$SCRIPT" ] + then + CHANGED="" + else + SCRIPT="$REALPATH" + fi +done + +# Get the location of the script. +REALDIR=`dirname "$REALPATH"` +# Normalize the path +REALDIR=`cd "${REALDIR}"; pwd` + +# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if +# the working directory is later changed. +FIRST_CHAR=`echo $PIDDIR | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + PIDDIR=$REALDIR/$PIDDIR +fi +# Same test for WRAPPER_CMD +FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + WRAPPER_CMD=$REALDIR/$WRAPPER_CMD +fi +# Same test for WRAPPER_CONF +FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1` +if [ "$FIRST_CHAR" != "/" ] +then + WRAPPER_CONF=$REALDIR/$WRAPPER_CONF +fi + +# Process ID +ANCHORFILE="$PIDDIR/$APP_NAME.anchor" +COMMANDFILE="$PIDDIR/$APP_NAME.command" +STATUSFILE="$PIDDIR/$APP_NAME.status" +JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status" +PIDFILE="$PIDDIR/$APP_NAME.pid" +LOCKDIR="/var/lock/subsys" +LOCKFILE="$LOCKDIR/$APP_NAME" +pid="" + +# Resolve the location of the 'ps' command +PS_BIN="/usr/ucb/ps" + if [ ! -x "$PS_BIN" ] + then + PS_BIN="/usr/bin/ps" + if [ ! -x "$PS_BIN" ] + then + PS_BIN="/bin/ps" + if [ ! -x "$PS_BIN" ] + then + eval echo `gettext 'Unable to locate "ps".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi + fi + fi + +TR_BIN="/usr/bin/tr" +if [ ! -x "$TR_BIN" ] +then + TR_BIN="/bin/tr" + if [ ! -x "$TR_BIN" ] + then + eval echo `gettext 'Unable to locate "tr".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi +fi +# Resolve the os +DIST_OS=`uname -s | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` +case "$DIST_OS" in + 'sunos') + DIST_OS="solaris" + ;; + 'hp-ux' | 'hp-ux64') + # HP-UX needs the XPG4 version of ps (for -o args) + DIST_OS="hpux" + UNIX95="" + export UNIX95 + ;; + 'darwin') + DIST_OS="macosx" + ;; + 'unix_sv') + DIST_OS="unixware" + ;; + 'os/390') + DIST_OS="zos" + ;; +esac + +# Compare Versions $1<$2=0, $1==$2=1, $1>$2=2 +compareVersions () { + if [ "$1" = "$2" ] + then + return 1 + else + local i=1 + while true + do + local v1=`echo "$1" | cut -d '.' -f $i` + local v2=`echo "$2" | cut -d '.' -f $i` + if [ "X$v1" = "X" ] + then + if [ "X$v2" = "X" ] + then + return 1 + fi + v1="0" + elif [ "X$v2" = "X" ] + then + v2="0" + fi + if [ $v1 -lt $v2 ] + then + return 0 + elif [ $v1 -gt $v2 ] + then + return 2 + fi + i=`expr $i + 1` + done + fi +} + +# Resolve the architecture +if [ "$DIST_OS" = "macosx" ] +then + OS_VER=`sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\|[0-9]*\.[0-9]*'` + DIST_ARCH="universal" + compareVersions "$OS_VER" "10.5.0" + if [[ $? < 1 ]] + then + DIST_BITS="32" + KEY_KEEP_ALIVE="OnDemand" + else + # Note: "OnDemand" has been deprecated and replaced from Mac OS X 10.5 by "KeepAlive" + KEY_KEEP_ALIVE="KeepAlive" + + if [ "X`/usr/sbin/sysctl -n hw.cpu64bit_capable`" = "X1" ] + then + DIST_BITS="64" + else + DIST_BITS="32" + fi + fi + APP_PLIST_BASE=${PLIST_DOMAIN}.${APP_NAME} + APP_PLIST=${APP_PLIST_BASE}.plist +else + if [ "$DIST_OS" = "linux" ] + then + DIST_ARCH= + else + DIST_ARCH=`uname -p 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` + fi + if [ "X$DIST_ARCH" = "X" ] + then + DIST_ARCH="unknown" + fi + if [ "$DIST_ARCH" = "unknown" ] + then + DIST_ARCH=`uname -m 2>/dev/null | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` + fi + case "$DIST_ARCH" in + 'athlon' | 'i386' | 'i486' | 'i586' | 'i686') + DIST_ARCH="x86" + if [ "${DIST_OS}" = "solaris" ] ; then + DIST_BITS=`isainfo -b` + else + DIST_BITS="32" + fi + ;; + 'amd64' | 'x86_64') + DIST_ARCH="x86" + DIST_BITS="64" + ;; + 'ia32') + DIST_ARCH="ia" + DIST_BITS="32" + ;; + 'ia64' | 'ia64n' | 'ia64w') + DIST_ARCH="ia" + DIST_BITS="64" + ;; + 'ip27') + DIST_ARCH="mips" + DIST_BITS="32" + ;; + 'power' | 'powerpc' | 'power_pc' | 'ppc64') + if [ "${DIST_ARCH}" = "ppc64" ] ; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + DIST_ARCH="ppc" + if [ "${DIST_OS}" = "aix" ] ; then + if [ `getconf KERNEL_BITMODE` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + fi + ;; + 'pa_risc' | 'pa-risc') + DIST_ARCH="parisc" + if [ `getconf KERNEL_BITS` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + ;; + 'sun4u' | 'sparcv9' | 'sparc') + DIST_ARCH="sparc" + DIST_BITS=`isainfo -b` + ;; + '9000/800' | '9000/785') + DIST_ARCH="parisc" + if [ `getconf KERNEL_BITS` -eq 64 ]; then + DIST_BITS="64" + else + DIST_BITS="32" + fi + ;; + '2064' | '2066' | '2084' | '2086' | '2094' | '2096' | '2097' | '2098' | '2817') + DIST_ARCH="390" + DIST_BITS="64" + ;; + armv*) + if [ -z "`readelf -A /proc/self/exe | grep Tag_ABI_VFP_args`" ] ; then + DIST_ARCH="armel" + DIST_BITS="32" + else + DIST_ARCH="armhf" + DIST_BITS="32" + fi + ;; + esac +fi + +# OSX always places Java in the same location so we can reliably set JAVA_HOME +if [ "$DIST_OS" = "macosx" ] +then + if [ -z "$JAVA_HOME" ]; then + if [ -x /usr/libexec/java_home ]; then + JAVA_HOME=`/usr/libexec/java_home`; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi +fi + +# Test Echo +ECHOTEST=`echo -n "x"` +if [ "$ECHOTEST" = "x" ] +then + ECHOOPT="-n " + ECHOOPTC="" +else + ECHOOPT="" + ECHOOPTC="\c" +fi + + +gettext() { + "$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null + if [ $? != 0 ] ; then + echo "$1" + fi +} + +outputFile() { + if [ -f "$1" ] + then + eval echo `gettext ' $1 Found but not executable.'`; + else + echo " $1" + fi +} + +# Decide on the wrapper binary to use. +# If the bits of the OS could be detected, we will try to look for the +# binary with the correct bits value. If it doesn't exist, fall back +# and look for the 32-bit binary. If that doesn't exist either then +# look for the default. +WRAPPER_TEST_CMD="" +if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" -a -z "$WRAPPER_TEST_CMD" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -f "$WRAPPER_CMD" -a -z "$WRAPPER_TEST_CMD" ] +then + WRAPPER_TEST_CMD="$WRAPPER_CMD" + if [ ! -x "$WRAPPER_TEST_CMD" ] + then + chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null + fi + if [ -x "$WRAPPER_TEST_CMD" ] + then + WRAPPER_CMD="$WRAPPER_TEST_CMD" + else + outputFile "$WRAPPER_TEST_CMD" + WRAPPER_TEST_CMD="" + fi +fi +if [ -z "$WRAPPER_TEST_CMD" ] +then + eval echo `gettext 'Unable to locate any of the following binaries:'` + outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" + if [ ! "$DIST_BITS" = "32" ] + then + outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" + fi + outputFile "$WRAPPER_CMD" + + exit 1 +fi + + +# Build the nice clause +if [ "X$PRIORITY" = "X" ] +then + CMDNICE="" +else + CMDNICE="nice -$PRIORITY" +fi + +# Build the anchor file clause. +if [ "X$IGNORE_SIGNALS" = "X" ] +then + ANCHORPROP= + IGNOREPROP= +else + ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\" + IGNOREPROP=wrapper.ignore_signals=TRUE +fi + +# Build the status file clause. +if [ "X$DETAIL_STATUS$WAIT_FOR_STARTED_STATUS" = "X" ] +then + STATUSPROP= +else + STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\"" +fi + +# Build the command file clause. +if [ -n "$PAUSABLE" ] +then + COMMANDPROP="wrapper.commandfile=\"$COMMANDFILE\" wrapper.pausable=TRUE" +else + COMMANDPROP= +fi + +if [ ! -n "$WAIT_FOR_STARTED_STATUS" ] +then + WAIT_FOR_STARTED_STATUS=true +fi + +if [ $WAIT_FOR_STARTED_STATUS = true ] ; then + DETAIL_STATUS=true +fi + + +# Build the lock file clause. Only create a lock file if the lock directory exists on this platform. +LOCKPROP= +if [ -d $LOCKDIR ] +then + if [ -w $LOCKDIR ] + then + LOCKPROP=wrapper.lockfile=\"$LOCKFILE\" + fi +fi + +# Build app name clause +if [ ! -n "$APP_NAME_PASS_TO_WRAPPER" ] +then + APP_NAME_PASS_TO_WRAPPER=true +fi +if [ $APP_NAME_PASS_TO_WRAPPER = false ] +then + APPNAMEPROP= +else + APPNAMEPROP="wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\"" +fi + +# Decide on run levels. +RUN_LEVEL_S_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_S_${DIST_OS}\}"` +RUN_LEVEL_S_DIST_OS=`eval "echo ${RUN_LEVEL_S_DIST_OS_TMP}"` +if [ "X${RUN_LEVEL_S_DIST_OS}" != "X" ] ; then + APP_RUN_LEVEL_S=${RUN_LEVEL_S_DIST_OS} +elif [ "X$RUN_LEVEL_S" != "X" ] ; then + APP_RUN_LEVEL_S=$RUN_LEVEL_S +else + APP_RUN_LEVEL_S=$RUN_LEVEL +fi +APP_RUN_LEVEL_S_CHECK=`echo "$APP_RUN_LEVEL_S" | sed "s/[(0-9)*]/0/g"` +if [ "X${APP_RUN_LEVEL_S_CHECK}" != "X00" ] ; then + eval echo `gettext 'Run level \"${APP_RUN_LEVEL_S}\" must be numeric and have a length of two \(00-99\).'` + exit 1; +fi +RUN_LEVEL_K_DIST_OS_TMP=`eval "echo \$\{RUN_LEVEL_K_${DIST_OS}\}"` +RUN_LEVEL_K_DIST_OS=`eval "echo ${RUN_LEVEL_K_DIST_OS_TMP}"` +if [ "X${RUN_LEVEL_K_DIST_OS}" != "X" ] ; then + APP_RUN_LEVEL_K=${RUN_LEVEL_K_DIST_OS} +elif [ "X$RUN_LEVEL_K" != "X" ] ; then + APP_RUN_LEVEL_K=$RUN_LEVEL_K +else + APP_RUN_LEVEL_K=$RUN_LEVEL +fi +APP_RUN_LEVEL_K_CHECK=`echo "$APP_RUN_LEVEL_K" | sed "s/[(0-9)*]/0/g"` +if [ "X${APP_RUN_LEVEL_K_CHECK}" != "X00" ] ; then + eval echo `gettext 'Run level \"${APP_RUN_LEVEL_K}\" must be numeric and have a length of two \(00-99\).'` + exit 1; +fi + +prepAdditionalParams() { + ADDITIONAL_PARA="" + if [ ! -n "$PASS_THROUGH" ] + then + PASS_THROUGH=false + fi + if [ $PASS_THROUGH = true ] ; then + ADDITIONAL_PARA="--" + while [ -n "$1" ] ; do + ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\"" + shift + done + elif [ -n "$1" ] ; then + eval echo `gettext "WARNING: Extra arguments will be ignored. Please run \'$0 help\' for usage."` + fi +} + +checkUser() { + # $1 touchLock flag + # $2.. [command] args + + # Check the configured user. If necessary rerun this script as the desired user. + if [ "X$RUN_AS_USER" != "X" ] + then + # Resolve the location of the 'id' command + ID_BIN="/usr/xpg4/bin/id" + if [ ! -x "$ID_BIN" ] + then + ID_BIN="/usr/bin/id" + if [ ! -x "$ID_BIN" ] + then + eval echo `gettext 'Unable to locate "id".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + fi + fi + + if [ "`$ID_BIN -u -n`" = "$RUN_AS_USER" ] + then + # Already running as the configured user. Avoid password prompts by not calling su. + RUN_AS_USER="" + fi + fi + if [ "X$RUN_AS_USER" != "X" ] + then + if [ "`$ID_BIN -u -n "$RUN_AS_USER" 2>/dev/null`" != "$RUN_AS_USER" ] + then + eval echo `gettext 'User $RUN_AS_USER does not exist.'` + exit 1 + fi + + # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be + # able to create the lock file. The Wrapper will be able to update this file once it + # is created but will not be able to delete it on shutdown. If $1 is set then + # the lock file should be created for the current command + if [ "X$LOCKPROP" != "X" ] + then + if [ "X$1" != "X" ] + then + # Resolve the primary group + RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1` + if [ "X$RUN_AS_GROUP" = "X" ] + then + RUN_AS_GROUP=$RUN_AS_USER + fi + touch $LOCKFILE + chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE + fi + fi + + # Still want to change users, recurse. This means that the user will only be + # prompted for a password once. Variables shifted by 1 + shift + + # Wrap the parameters so they can be passed. + ADDITIONAL_PARA="" + while [ -n "$1" ] ; do + if [ "$1" = 'installstart' ] ; then + # At this point the service is already installed. When we will fork the process we only need to start the service. + ADDITIONAL_PARA="$ADDITIONAL_PARA \"start\"" + else + ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\"" + fi + shift + done + + # Use "runuser" if this exists. + # runuser should be used on RedHat in preference to su. + if test -f "/sbin/runuser" + then + /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA" + else + $SU_BIN - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA" $SU_OPTS + fi + RUN_AS_USER_EXITCODE=$? + + # we check if the previous command has failed + if [ $RUN_AS_USER_EXITCODE -ne 0 ] + then + if [ $RUN_AS_USER_EXITCODE -eq 1 ] + then + checkForkCommand + else + eval echo `gettext 'Error executing the requested command with user \"$RUN_AS_USER\" \(error code $RUN_AS_USER_EXITCODE\).'` + echo "" + fi + fi + + # Now that we are the original user again, we may need to clean up the lock file. + if [ "X$LOCKPROP" != "X" ] + then + getpid + if [ "X$pid" = "X" ] + then + # Wrapper is not running so make sure the lock file is deleted. + if [ -f "$LOCKFILE" ] + then + rm "$LOCKFILE" + fi + fi + fi + + exit $RUN_AS_USER_EXITCODE + fi +} + +# Try to fork by executing a simple command. +# With this function, we want to make sure we are able to fork. +checkForkCommand() { + + if test -f "/sbin/runuser" + then + /sbin/runuser - $RUN_AS_USER -c "ls \"$REALPATH\"" > /dev/null 2>&1 & + else + $SU_BIN - $RUN_AS_USER -c "ls \"$REALPATH\"" $SU_OPTS > /dev/null 2>&1 & + fi + CHECK_EXITCODE=$? + + if [ $CHECK_EXITCODE -ne 0 ] + then + # clearly a problem with forking + eval echo `gettext 'Error: unable to create fork process.'` + eval echo `gettext 'Advice:'` + eval echo `gettext 'One possible cause of failure is when the user \(\"$RUN_AS_USER\"\) has no shell.'` + eval echo `gettext 'In this case, two solutions are available by editing the script file:'` + eval echo `gettext '1. Use \"SU_OPTS\" to set the shell for the user.'` + eval echo `gettext '2. Use a OS service management tool (only available on some platforms).'` + echo "" + fi +} + +getpid() { + pid="" + if [ -f "$PIDFILE" ] + then + if [ -r "$PIDFILE" ] + then + pid=`cat "$PIDFILE"` + if [ "X$pid" != "X" ] + then + if [ "X$PIDFILE_CHECK_PID" != "X" ] + then + # It is possible that 'a' process with the pid exists but that it is not the + # correct process. This can happen in a number of cases, but the most + # common is during system startup after an unclean shutdown. + # The ps statement below looks for the specific wrapper command running as + # the pid. If it is not found then the pid file is considered to be stale. + case "$DIST_OS" in + 'freebsd') + pidtest=`$PS_BIN -p $pid -o args | tail -1` + if [ "X$pidtest" = "XCOMMAND" ] + then + pidtest="" + fi + ;; + 'macosx') + pidtest=`$PS_BIN -ww -p $pid -o command | grep -F "$WRAPPER_CMD" | tail -1` + ;; + 'solaris') + if [ -f "/usr/bin/pargs" ] + then + pidtest=`pargs $pid | fgrep "$WRAPPER_CMD" | tail -1` + else + case "$PS_BIN" in + '/usr/ucb/ps') + pidtest=`$PS_BIN -auxww $pid | fgrep "$WRAPPER_CMD" | tail -1` + ;; + '/usr/bin/ps') + TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1` + ;; + '/bin/ps') + TRUNCATED_CMD=`$PS_BIN -o comm -p $pid | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + fi + ;; + 'hpux') + pidtest=`$PS_BIN -p $pid -x -o args | grep -F "$WRAPPER_CMD" | tail -1` + ;; + 'zos') + TRUNCATED_CMD=`$PS_BIN -p $pid -o args | tail -1` + COUNT=`echo $TRUNCATED_CMD | wc -m` + COUNT=`echo ${COUNT}` + COUNT=`expr $COUNT - 1` + TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT` + pidtest=`$PS_BIN -p $pid -o args | grep -F "$TRUNCATED_CMD" | tail -1` + ;; + *) + pidtest=`$PS_BIN -p $pid -o args | grep -F "$WRAPPER_CMD" | tail -1` + ;; + esac + else + # Check to see whether the pid exists as a running process, but in this mode, don't check what that pid is. + case "$DIST_OS" in + 'solaris') + case "$PS_BIN" in + '/usr/ucb/ps') + pidtest=`$PS_BIN $pid | grep "$pid" | awk '{print $1}' | tail -1` + ;; + '/usr/bin/ps') + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + '/bin/ps') + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + ;; + *) + pidtest=`$PS_BIN -p $pid -o pid | grep "$pid" | tail -1` + ;; + esac + fi + + if [ "X$pidtest" = "X" ] + then + # This is a stale pid file. + rm -f "$PIDFILE" + eval echo `gettext 'Removed stale pid file: $PIDFILE'` + pid="" + fi + fi + else + eval echo `gettext 'Cannot read $PIDFILE.'` + exit 1 + fi + fi +} + +getstatus() { + STATUS= + if [ -f "$STATUSFILE" ] + then + if [ -r "$STATUSFILE" ] + then + STATUS=`cat "$STATUSFILE"` + fi + fi + if [ "X$STATUS" = "X" ] + then + STATUS="Unknown" + fi + + JAVASTATUS= + if [ -f "$JAVASTATUSFILE" ] + then + if [ -r "$JAVASTATUSFILE" ] + then + JAVASTATUS=`cat "$JAVASTATUSFILE"` + fi + fi + if [ "X$JAVASTATUS" = "X" ] + then + JAVASTATUS="Unknown" + fi +} + +testpid() { + case "$DIST_OS" in + 'solaris') + case "$PS_BIN" in + '/usr/ucb/ps') + pid=`$PS_BIN $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + '/usr/bin/ps') + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + '/bin/ps') + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + ;; + *) + echo "Unsupported ps command $PS_BIN" + exit 1 + ;; + esac + ;; + *) + pid=`$PS_BIN -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null + ;; + esac + if [ "X$pid" = "X" ] + then + # Process is gone so remove the pid file. + rm -f "$PIDFILE" + pid="" + fi +} + +launchdtrap() { + stopit + exit +} + +waitforwrapperstop() { + getpid + while [ "X$pid" != "X" ] ; do + sleep 1 + getpid + done +} + +launchinternal() { + getpid + trap launchdtrap TERM + if [ "X$pid" = "X" ] + then + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + # launchd expects that this script stay up and running so we need to do our own monitoring of the Wrapper process. + if [ $WAIT_FOR_STARTED_STATUS = true ] + then + waitforwrapperstop + fi +} + +console() { + eval echo `gettext 'Running $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + trap '' 3 + + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" $APPNAMEPROP $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi +} + +waitforjavastartup() { + getstatus + eval echo $ECHOOPT `gettext 'Waiting for $APP_LONG_NAME...$ECHOOPTC'` + + # Wait until the timeout or we have something besides Unknown. + counter=15 + while [ "$JAVASTATUS" = "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do + echo $ECHOOPT".$ECHOOPTC" + sleep 1 + getstatus + counter=`expr $counter - 1` + done + + if [ -n "$WAIT_FOR_STARTED_TIMEOUT" ] ; then + counter=$WAIT_FOR_STARTED_TIMEOUT + else + counter=120 + fi + while [ "$JAVASTATUS" != "STARTED" -a "$JAVASTATUS" != "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do + echo $ECHOOPT".$ECHOOPTC" + sleep 1 + getstatus + counter=`expr $counter - 1` + done + echo "" +} + +startwait() { + if [ $WAIT_FOR_STARTED_STATUS = true ] + then + waitforjavastartup + fi + # Sleep for a few seconds to allow for intialization if required + # then test to make sure we're still running. + # + i=0 + while [ $i -lt $WAIT_AFTER_STARTUP ] + do + sleep 1 + echo $ECHOOPT".$ECHOOPTC" + i=`expr $i + 1` + done + if [ $WAIT_AFTER_STARTUP -gt 0 -o $WAIT_FOR_STARTED_STATUS = true ] + then + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext ' WARNING: $APP_LONG_NAME may have failed to start.'` + exit 1 + else + eval echo `gettext ' running: PID:$pid'` + fi + else + echo "" + fi +} + +mustBeRootOrExit() { + if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then + eval echo `gettext 'Must be root to perform this action.'` + exit 1 + fi +} + + +macosxStart() { + # The daemon has been installed. + eval echo `gettext 'Starting $APP_LONG_NAME. Detected Mac OSX and installed launchd daemon.'` + mustBeRootOrExit + + getpid + if [ "X$pid" != "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + # If the daemon was just installed, it may not be loaded. + LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}` + if [ "X${LOADED_PLIST}" = "X" ] ; then + launchctl load /Library/LaunchDaemons/${APP_PLIST} + fi + # If launchd is set to run the daemon already at Load, we don't need to call start + getpid + if [ "X$pid" = "X" ] ; then + launchctl start ${APP_PLIST_BASE} + fi + + startwait +} + +macosxStop() { + # The daemon should be running. + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then + echo "" + eval echo `gettext 'Daemon is set to be kept continuously running and it will be automatically restarted.'` + eval echo `gettext 'To stop the daemon you need to uninstall it.'` + eval echo `gettext 'If you want to use the \"stop\" argument, you need to find MACOSX_KEEP_RUNNING'` + eval echo `gettext 'at the beginning of the script file and set it to \"false\".'` + echo "" + fi + launchctl stop ${APP_PLIST_BASE} + fi +} + +macosxRestart() { + # The daemon should be running. + eval echo `gettext 'Restarting $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "$MACOSX_KEEP_RUNNING" = "true" ] ; then + # by stopping it, launchd will automatically restart it + launchctl stop ${APP_PLIST_BASE} + else + launchctl unload "/Library/LaunchDaemons/${APP_PLIST}" + sleep 1 + launchctl load "/Library/LaunchDaemons/${APP_PLIST}" + fi + fi + + startwait +} + +upstartstart() { + # The daemon has been installed. + eval echo `gettext 'Starting $APP_LONG_NAME. Detected Linux and installed upstart.'` + mustBeRootOrExit + + getpid + if [ "X$pid" != "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + /sbin/start ${APP_NAME} + + startwait +} + +upstartStop() { + # The daemon has been installed. + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + fi + + /sbin/stop ${APP_NAME} +} + +upstartRestart() { + # The daemon has been installed. + eval echo `gettext 'Restarting $APP_LONG_NAME...'` + mustBeRootOrExit + + getpid + if [ "X$pid" = "X" ] ; then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + fi + + /sbin/restart ${APP_NAME} + + startwait +} + +systemdInstall() { + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using systemd...'` + if [ -f "${REALDIR}/${APP_NAME}.service" ] ; then + eval echo `gettext ' a custom service file ${APP_NAME}.service found'` + cp "${REALDIR}/${APP_NAME}.service" "${SYSTEMD_SERVICE_FILE}" + else + eval echo `gettext ' creating default service file...'` + echo "[Unit]" > "${SYSTEMD_SERVICE_FILE}" + echo "Description=${APP_LONG_NAME}" >> "${SYSTEMD_SERVICE_FILE}" + echo "After=syslog.target" >> "${SYSTEMD_SERVICE_FILE}" + echo "" >> "${SYSTEMD_SERVICE_FILE}" + echo "[Service]" >> "${SYSTEMD_SERVICE_FILE}" + echo "Type=forking" >> "${SYSTEMD_SERVICE_FILE}" + echo "ExecStart=${REALPATH} start sysd" >> "${SYSTEMD_SERVICE_FILE}" + echo "ExecStop=${REALPATH} stop sysd" >> "${SYSTEMD_SERVICE_FILE}" + if [ "X${RUN_AS_USER}" != "X" ] ; then + echo "User=${RUN_AS_USER}" >> "${SYSTEMD_SERVICE_FILE}" + fi + echo "" >> "${SYSTEMD_SERVICE_FILE}" + echo "[Install]" >> "${SYSTEMD_SERVICE_FILE}" + echo "WantedBy=multi-user.target" >> "${SYSTEMD_SERVICE_FILE}" + + systemctl daemon-reload + systemctl enable "${APP_NAME}" + fi +} + +systemdStart() { + # check if the service file is present + if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then + eval echo `gettext 'Reading file ${SYSTEMD_SERVICE_FILE}'` + else + eval echo `gettext 'No service file detected. Did you install the service?'` + exit 1 + fi + + systemctl start $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to start service $APP_NAME'` + exit 1 + fi + + startwait +} + +systemdStop() { + systemctl stop $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to stop service $APP_NAME'` + exit 1 + fi +} + +systemdRestart() { + systemctl restart $APP_NAME + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to restart service $APP_NAME'` + exit 1 + fi + + startwait +} + +systemdRemove() { + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from systemd...'` + systemctl disable $APP_NAME + rm "/etc/systemd/system/${APP_NAME}.service" + systemctl daemon-reload +} + +srcInstall() { + if [ "X$RUN_AS_USER" = "X" ] ; then + USERID="0" + else + USERID=`$ID_BIN -u "$RUN_AS_USER"` + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to get user id for $RUN_AS_USER'` + exit 1 + fi + fi + /usr/bin/mkssys -s "$APP_NAME" -p "$REALPATH" -a "launchdinternal" -u "$USERID" -f 9 -n 15 -S + /usr/sbin/mkitab "$APP_NAME":2:once:"/usr/bin/startsrc -s \"${APP_NAME}\" >/dev/console 2>&1" +} + +srcStart() { + startsrc -s "${APP_NAME}" + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to start service $APP_NAME'` + exit 1 + fi + + startwait +} + +srcStop() { + stopsrc -s "${APP_NAME}" + if [ $? -ne 0 ] ; then + eval echo `gettext 'Failed to stop service $APP_NAME'` + exit 1 + fi +} + +srcRestart() { + srcStop + srcStart +} + +start() { + eval echo `gettext 'Starting $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + prepAdditionalParams "$@" + + # The string passed to eval must handles spaces in paths correctly. + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.28 $ADDITIONAL_PARA" + eval $COMMAND_LINE + else + eval echo `gettext '$APP_LONG_NAME is already running.'` + exit 1 + fi + + startwait +} + +stopit() { + # $1 exit if down flag + + eval echo `gettext 'Stopping $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME was not running.'` + if [ "X$1" = "X1" ] + then + exit 1 + fi + else + if [ "X$IGNORE_SIGNALS" = "X" ] + then + # Running so try to stop it. + kill $pid + if [ $? -ne 0 ] + then + # An explanation for the failure should have been given + eval echo `gettext 'Unable to stop $APP_LONG_NAME.'` + exit 1 + fi + else + rm -f "$ANCHORFILE" + if [ -f "$ANCHORFILE" ] + then + # An explanation for the failure should have been given + eval echo `gettext 'Unable to stop $APP_LONG_NAME.'` + exit 1 + fi + fi + + # We can not predict how long it will take for the wrapper to + # actually stop as it depends on settings in wrapper.conf. + # Loop until it does. + savepid=$pid + CNT=0 + TOTCNT=0 + while [ "X$pid" != "X" ] + do + # Show a waiting message every 5 seconds. + if [ "$CNT" -lt "5" ] + then + CNT=`expr $CNT + 1` + else + eval echo `gettext 'Waiting for $APP_LONG_NAME to exit...'` + CNT=0 + fi + TOTCNT=`expr $TOTCNT + 1` + + sleep 1 + + testpid + done + + pid=$savepid + testpid + if [ "X$pid" != "X" ] + then + eval echo `gettext 'Failed to stop $APP_LONG_NAME.'` + exit 1 + else + eval echo `gettext 'Stopped $APP_LONG_NAME.'` + fi + fi +} + +pause() { + eval echo `gettext 'Pausing $APP_LONG_NAME.'` +} + +resume() { + eval echo `gettext 'Resuming $APP_LONG_NAME.'` +} + +status() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME is not running.'` + exit 1 + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME is running: PID:$pid'` + else + getstatus + eval echo `gettext '$APP_LONG_NAME is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + exit 0 + fi +} + +# Make sure APP_NAME is less than 14 characters, otherwise in AIX, the command +# "lsitab" will fail +validateAppNameLength() { + if [ ${#APP_NAME} -gt 14 ] ; then + eval echo `gettext ' APP_NAME (${APP_NAME}) must be less than 14 characters long'` + exit 1 + fi +} + +installUpstart() { + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using upstart..'` + if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then + eval echo `gettext ' a custom upstart conf file ${APP_NAME}.install found'` + cp "${REALDIR}/${APP_NAME}.install" "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' creating default upstart conf file..'` + echo "# ${APP_NAME} - ${APP_LONG_NAME}" > "/etc/init/${APP_NAME}.conf" + echo "description \"${APP_LONG_NAME}\"" >> "/etc/init/${APP_NAME}.conf" + echo "author \"Tanuki Software Ltd. \"" >> "/etc/init/${APP_NAME}.conf" + echo "start on runlevel [2345]" >> "/etc/init/${APP_NAME}.conf" + echo "stop on runlevel [!2345]" >> "/etc/init/${APP_NAME}.conf" + echo "env LANG=${LANG}" >> "/etc/init/${APP_NAME}.conf" + echo "exec \"${REALPATH}\" upstartinternal" >> "/etc/init/${APP_NAME}.conf" + fi +} + +installdaemon() { + mustBeRootOrExit + + APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"` + if [ "$DIST_OS" = "solaris" ] ; then + eval echo `gettext 'Detected Solaris:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + fi + elif [ "$DIST_OS" = "linux" ] ; then + if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then + eval echo `gettext 'Detected RHEL or Fedora:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + else + if [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then + installUpstart + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + /sbin/chkconfig --add "$APP_NAME" + /sbin/chkconfig "$APP_NAME" on + fi + fi + elif [ -f /etc/SuSE-release ] ; then + eval echo `gettext 'Detected SuSE or SLES:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + insserv "/etc/init.d/$APP_NAME" + fi + elif [ -f /etc/lsb-release -o -f /etc/debian_version -o -f /etc/debian_release ] ; then + eval echo `gettext 'Detected Ubuntu or Debian:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + if [ -n "$USE_SYSTEMD" -a -d "/etc/systemd" ] ; then + systemdInstall + elif [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then + installUpstart + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon using init.d..'` + ln -s "$REALPATH" "/etc/init.d/$APP_NAME" + update-rc.d "$APP_NAME" defaults + fi + fi + else + eval echo `gettext 'Detected Linux:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" /etc/init.d/$APP_NAME + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + fi + fi + elif [ "$DIST_OS" = "hpux" ] ; then + eval echo `gettext 'Detected HP-UX:'` + if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + ln -s "$REALPATH" "/sbin/init.d/$APP_NAME" + for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" + ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" + fi + elif [ "$DIST_OS" = "aix" ] ; then + eval echo `gettext 'Detected AIX:'` + validateAppNameLength + if [ -f "/etc/rc.d/init.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as rc.d script.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + elif [ -n "`/usr/sbin/lsitab $APP_NAME`" -a -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as SRC service.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + if [ -n "`/usr/sbin/lsitab install_assist`" ] ; then + eval echo `gettext ' The task /usr/sbin/install_assist was found in the inittab, this might cause problems for all subsequent tasks to launch at this process is known to block the init task. Please make sure this task is not needed anymore and remove/deactivate it.'` + fi + for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do + eval echo `gettext ' Removing unexpected file before proceeding: $i'` + rm -f $i + done + srcInstall + fi + elif [ "$DIST_OS" = "freebsd" ] ; then + eval echo `gettext 'Detected FreeBSD:'` + if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf + if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then + ln -s "${REALDIR}/${APP_NAME}.install" "/etc/rc.d/$APP_NAME" + else + echo '#!/bin/sh' > "/etc/rc.d/$APP_NAME" + echo "#" >> "/etc/rc.d/$APP_NAME" + echo "# PROVIDE: $APP_NAME" >> "/etc/rc.d/$APP_NAME" + echo "# REQUIRE: NETWORKING" >> "/etc/rc.d/$APP_NAME" + echo "# KEYWORD: shutdown" >> "/etc/rc.d/$APP_NAME" + echo ". /etc/rc.subr" >> "/etc/rc.d/$APP_NAME" + echo "name=\"$APP_NAME\"" >> "/etc/rc.d/$APP_NAME" + echo "rcvar=\`set_rcvar\`" >> "/etc/rc.d/$APP_NAME" + echo "command=\"${REALPATH}\"" >> "/etc/rc.d/$APP_NAME" + echo 'start_cmd="${name}_start"' >> "/etc/rc.d/$APP_NAME" + echo 'load_rc_config $name' >> "/etc/rc.d/$APP_NAME" + echo 'status_cmd="${name}_status"' >> "/etc/rc.d/$APP_NAME" + echo 'stop_cmd="${name}_stop"' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_status() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} status' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_stop() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} stop' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo "${APP_NAME}_start() {" >> "/etc/rc.d/$APP_NAME" + echo '${command} start' >> "/etc/rc.d/$APP_NAME" + echo '}' >> "/etc/rc.d/$APP_NAME" + echo 'run_rc_command "$1"' >> "/etc/rc.d/$APP_NAME" + fi + echo "${APP_NAME}_enable=\"YES\"" >> /etc/rc.conf + chmod 555 "/etc/rc.d/$APP_NAME" + fi + elif [ "$DIST_OS" = "macosx" ] ; then + eval echo `gettext 'Detected Mac OSX:'` + if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + if [ -f "${REALDIR}/${APP_PLIST}" ] ; then + ln -s "${REALDIR}/${APP_PLIST}" "/Library/LaunchDaemons/${APP_PLIST}" + else + echo "" > "/Library/LaunchDaemons/${APP_PLIST}" + echo "> "/Library/LaunchDaemons/${APP_PLIST}" + echo "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo "" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " Label" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${APP_PLIST_BASE}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ProgramArguments" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${REALPATH}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " launchdinternal" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${KEY_KEEP_ALIVE}" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " <${MACOSX_KEEP_RUNNING}/>" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " RunAtLoad" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + if [ "X$RUN_AS_USER" != "X" ] ; then + echo " UserName" >> "/Library/LaunchDaemons/${APP_PLIST}" + echo " ${RUN_AS_USER}" >> "/Library/LaunchDaemons/${APP_PLIST}" + fi + echo " " >> "/Library/LaunchDaemons/${APP_PLIST}" + echo "" >> "/Library/LaunchDaemons/${APP_PLIST}" + fi + chmod 555 "/Library/LaunchDaemons/${APP_PLIST}" + fi + elif [ "$DIST_OS" = "zos" ] ; then + eval echo `gettext 'Detected z/OS:'` + if [ -f /etc/rc.bak ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + if [ "$COMMAND" != 'installstart' ] ; then + exit 1 + fi + else + eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'` + cp /etc/rc /etc/rc.bak + sed "s:echo /etc/rc script executed, \`date\`::g" /etc/rc.bak > /etc/rc + echo "_BPX_JOBNAME='${APP_NAME}' \"${REALDIR}/${APP_NAME}\" start" >>/etc/rc + echo '/etc/rc script executed, `date`' >>/etc/rc + fi + else + eval echo `gettext 'Install not currently supported for $DIST_OS'` + exit 1 + fi +} + +startdaemon() { + if [ "$DIST_OS" = "macosx" ] ; then + if [ ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext 'The $APP_LONG_NAME daemon is not currently installed.'` + else + macosxStart + fi + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartstart + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdStart + elif [ "$DIST_OS" = "aix" ] && [ -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcStart + else + if [ -n "$SYSD" ] ; then + shift + fi + + checkUser touchlock "$@" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + start "$@" + fi +} + +removedaemon() { + mustBeRootOrExit + + APP_NAME_LOWER=`echo "$APP_NAME" | $TR_BIN "[A-Z]" "[a-z]"` + if [ "$DIST_OS" = "solaris" ] ; then + eval echo `gettext 'Detected Solaris:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "linux" ] ; then + if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then + eval echo `gettext 'Detected RHEL or Fedora:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + /sbin/chkconfig "$APP_NAME" off + /sbin/chkconfig --del "$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'` + rm "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ -f /etc/SuSE-release ] ; then + eval echo `gettext 'Detected SuSE or SLES:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + insserv -r "/etc/init.d/$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ -f /etc/lsb-release -o -f /etc/debian_version -o -f /etc/debian_release ] ; then + eval echo `gettext 'Detected Ubuntu or Debian:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from init.d...'` + update-rc.d -f "$APP_NAME" remove + rm -f "/etc/init.d/$APP_NAME" + elif [ -n "$USE_SYSTEMD" -a -f "${SYSTEMD_SERVICE_FILE}" ] ; then + systemdRemove + elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'` + rm "/etc/init/${APP_NAME}.conf" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + else + eval echo `gettext 'Detected Linux:'` + if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + fi + elif [ "$DIST_OS" = "hpux" ] ; then + eval echo `gettext 'Detected HP-UX:'` + if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" "/sbin/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "aix" ] ; then + eval echo `gettext 'Detected AIX:'` + validateAppNameLength + if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -L "/etc/rc.d/init.d/$APP_NAME" -o -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -L "/etc/rc.d/init.d/$APP_NAME" ] ; then + for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" "/etc/rc.d/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + fi + if [ -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + /usr/sbin/rmitab $APP_NAME + /usr/bin/rmssys -s $APP_NAME + fi + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "freebsd" ] ; then + eval echo `gettext 'Detected FreeBSD:'` + if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + for i in "/etc/rc.d/$APP_NAME" + do + rm -f $i + done + sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "macosx" ] ; then + eval echo `gettext 'Detected Mac OSX:'` + if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + # Make sure the plist is installed + LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}` + if [ "X${LOADED_PLIST}" != "X" ] ; then + launchctl unload "/Library/LaunchDaemons/${APP_PLIST}" + fi + rm -f "/Library/LaunchDaemons/${APP_PLIST}" + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + elif [ "$DIST_OS" = "zos" ] ; then + eval echo `gettext 'Detected z/OS:'` + if [ -f /etc/rc.bak ] ; then + stopit "0" + eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + cp /etc/rc /etc/rc.bak + sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc + rm /etc/rc.bak + else + eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` + exit 1 + fi + else + eval echo `gettext 'Remove not currently supported for $DIST_OS'` + exit 1 + fi +} + +dump() { + eval echo `gettext 'Dumping $APP_LONG_NAME...'` + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext '$APP_LONG_NAME was not running.'` + else + kill -3 $pid + + if [ $? -ne 0 ] + then + eval echo `gettext 'Failed to dump $APP_LONG_NAME.'` + exit 1 + else + eval echo `gettext 'Dumped $APP_LONG_NAME.'` + fi + fi +} + +# Used by HP-UX init scripts. +startmsg() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Stopped'` + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Running'` + else + getstatus + eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + fi +} + +# Used by HP-UX init scripts. +stopmsg() { + getpid + if [ "X$pid" = "X" ] + then + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Stopped'` + else + if [ "X$DETAIL_STATUS" = "X" ] + then + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Running'` + else + getstatus + eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'` + fi + fi +} + +showUsage() { + # $1 bad command + + if [ -n "$1" ] + then + eval echo `gettext 'Unexpected command: $1'` + echo ""; + fi + + eval MSG=`gettext 'Usage: '` + if [ -n "$FIXED_COMMAND" ] ; then + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 {JavaAppArgs}" + else + echo "${MSG} $0" + fi + else + if [ -n "$PAUSABLE" ] ; then + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | pause | resume | status | install | installstart | remove | dump ]" + else + echo "${MSG} $0 [ console | start | stop | restart | condrestart | pause | resume | status | install | installstart | remove | dump ]" + fi + else + if [ -n "$PASS_THROUGH" ] ; then + echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | status | install | installstart | remove | dump ]" + else + echo "${MSG} $0 [ console | start | stop | restart | condrestart | status | install | installstart | remove | dump ]" + fi + fi + fi + + if [ ! -n "$BRIEF_USAGE" ] + then + echo ""; + if [ ! -n "$FIXED_COMMAND" ] ; then + echo "`gettext 'Commands:'`" + echo "`gettext ' console Launch in the current console.'`" + echo "`gettext ' start Start in the background as a daemon process.'`" + echo "`gettext ' stop Stop if running as a daemon or in another console.'`" + echo "`gettext ' restart Stop if running and then start.'`" + echo "`gettext ' condrestart Restart only if already running.'`" + if [ -n "$PAUSABLE" ] ; then + echo "`gettext ' pause Pause if running.'`" + echo "`gettext ' resume Resume if paused.'`" + fi + echo "`gettext ' status Query the current status.'`" + echo "`gettext ' install Install to start automatically when system boots.'`" + echo "`gettext ' installstart Install and start running as a daemon process.'`" + echo "`gettext ' remove Uninstall.'`" + echo "`gettext ' dump Request a Java thread dump if running.'`" + echo ""; + fi + if [ -n "$PASS_THROUGH" ] ; then + echo "`gettext 'JavaAppArgs: Zero or more arguments which will be passed to the Java application.'`" + echo ""; + fi + fi + + exit 1 +} + +docommand() { + case "$COMMAND" in + 'console') + checkUser touchlock "$@" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + console "$@" + ;; + + 'start') + startdaemon "$@" + ;; + + 'stop') + if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + macosxStop + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartStop + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdStop + elif [ "$DIST_OS" = "aix" ] && [ "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcStop + else + checkUser "" "$COMMAND" + stopit "0" + fi + ;; + + 'restart') + if [ "$DIST_OS" = "macosx" ] ; then + if [ ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + eval echo `gettext '$APP_NAME was not installed.'` + else + macosxRestart + fi + elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then + upstartRestart + elif [ "$DIST_OS" = "linux" -a -n "$USE_SYSTEMD" -a -z "$SYSD" ] ; then + systemdRestart + elif [ "$DIST_OS" = "aix" ] && [ "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then + srcRestart + else + if [ -n "$SMF" ] ; then + shift + fi + checkUser touchlock "$COMMAND" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + stopit "0" + start "$@" + fi + ;; + + 'condrestart') + checkUser touchlock "$COMMAND" + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + stopit "1" + start "$@" + ;; + + 'pause') + if [ -n "$PAUSABLE" ] + then + pause + else + showUsage "$COMMAND" + fi + ;; + + 'resume') + if [ -n "$PAUSABLE" ] + then + resume + else + showUsage "$COMMAND" + fi + ;; + + 'status') + status + ;; + + 'install') + installdaemon "$@" + ;; + + 'installstart') + installdaemon "$@" + startdaemon "$@" + ;; + + 'remove') + removedaemon + ;; + + 'dump') + checkUser "" "$COMMAND" + dump + ;; + + 'start_msg') + # Internal command called by launchd on HP-UX. + checkUser "" "$COMMAND" + startmsg + ;; + + 'stop_msg') + # Internal command called by launchd on HP-UX. + checkUser "" "$COMMAND" + stopmsg + ;; + + 'launchdinternal' | 'upstartinternal') + if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then + checkUser touchlock "$@" + fi + # Internal command called by launchd on Max OSX. + # We do not want to call checkUser here as it is handled in the launchd plist file. Doing it here would confuse launchd. + if [ ! -n "$FIXED_COMMAND" ] ; then + shift + fi + launchinternal "$@" + ;; + + *) + showUsage "$COMMAND" + ;; + esac +} + +docommand "$@" + +exit 0 diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/pause.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/pause.bat new file mode 100644 index 0000000..65a2166 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/pause.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -a %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -a %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/query.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/query.bat new file mode 100644 index 0000000..5638a44 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/query.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -q %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -q %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/resume.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/resume.bat new file mode 100644 index 0000000..8b4d6ea --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/resume.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -e %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -e %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/run.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/run.bat new file mode 100644 index 0000000..8672708 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/run.bat @@ -0,0 +1,156 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. +rem +rem ******************************************************************** +rem NOTE - This script has been modified to run the TestWrapper sample +rem application and should NOT be used as a base for your own +rem applications. All of the documentation assumes that you are +rem working from the default source script: +rem WRAPPER_HOME/src/bin/App.bat.in +rem ******************************************************************** +rem +rem ******************************************************************** +rem NOTE - This script has been modified to run the TestWrapper sample +rem application and should NOT be used as a base for your own +rem applications. All of the documentation assumes that you are +rem working from the default source script: +rem WRAPPER_HOME/src/bin/App.bat.in +rem ******************************************************************** + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM +rem as is. +rem If _WRAPPER_CONF_OVERRIDE is specified then all parameters will be passed. +rem If not set then all parameters starting with the second will be passed. +set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/start.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/start.bat new file mode 100644 index 0000000..d7d5e85 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/start.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -t %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -t %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/stop.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/stop.bat new file mode 100644 index 0000000..49d717c --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/stop.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -p %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -p %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/uninstall.bat b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/uninstall.bat new file mode 100644 index 0000000..6ee6d07 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/uninstall.bat @@ -0,0 +1,135 @@ +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2016 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.28 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located. It can be +rem either an absolute or a relative path. If the path contains any special +rem characters, please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup +if not [%_PASS_THROUGH%]==[true] ( + if not [%1]==[] ( + echo WARNING: Extra arguments will be ignored. Please check usage in the batch file. + ) +) + +rem Collect the application parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if not [%_PASS_THROUGH%]==[true] ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-32 b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-32 new file mode 100644 index 0000000..ff3509f Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-32 differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-64 b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-64 new file mode 100644 index 0000000..e72b0e0 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-linux-x86-64 differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-32 b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-32 new file mode 100644 index 0000000..9a36a5c Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-32 differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-64 b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-64 new file mode 100644 index 0000000..6587d2c Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-macosx-universal-64 differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-32.exe b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-32.exe new file mode 100644 index 0000000..9762dbf Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-32.exe differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-64.exe b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-64.exe new file mode 100644 index 0000000..122ec17 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/bin/wrapper-windows-x86-64.exe differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/application.properties b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/application.properties new file mode 100644 index 0000000..b48ea7d --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/application.properties @@ -0,0 +1,49 @@ +#application +application.name=food-mq +application.owner= + +#RabbitMQ +spring.rabbitmq.host=127.0.0.1 +spring.rabbitmq.port=5672 +spring.rabbitmq.virtualHost=/dev_test +spring.rabbitmq.publisherConfirms=true +spring.rabbitmq.username=guest +spring.rabbitmq.password=guest + +# Dubbo service version +food.service.group=default +food.service.version=2.0.0 + +# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service +dubbo.scan.basePackages=com.jwsaas + +# Dubbo Config properties +## ApplicationConfig Bean +dubbo.application.id=food-mq +dubbo.application.name=food-mq +dubbo.application.qos-enable=false +dubbo.application.qos-port=22222 + +## ConsumerConfig Bean +dubbo.consumer.id=dubbo +dubbo.consumer.name=dubbo +dubbo.consumer.client=netty4 + +## RegistryConfig Bean +dubbo.registry.id=food-registry +dubbo.registry.address=zookeeper://127.0.0.1:2181 +dubbo.registry.client=curator +dubbo.registry.file=/home/project/foodv2/dubbo/food-mq.cache + +## consume +dubbo.consumer.timeout=600000 +# \u670D\u52A1\u542F\u52A8\u65F6\u68C0\u67E5\u88AB\u8C03\u7528\u670D\u52A1\u662F\u5426\u53EF\u7528 +dubbo.consumer.check=true +dubbo.consumer.retries=0 + +#MQTT +mqtt.clientId=cy2_foodmq_kaifa_01 +mqtt.host=iotv2.ffcygl.com +mqtt.port=18830 +mqtt.keepalive=60 +mqtt.connection.timeout=10 diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/logback.xml b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/logback.xml new file mode 100644 index 0000000..be9e3e2 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/logback.xml @@ -0,0 +1,24 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] %logger{120} - %msg %n + + + + + + + + + + + + + + + + + diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/wrapper.conf b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/wrapper.conf new file mode 100644 index 0000000..93620a2 --- /dev/null +++ b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/conf/wrapper.conf @@ -0,0 +1,60 @@ +encoding=UTF-8 +wrapper.lang=zh_CN +#using the system default JDK environment variable +wrapper.java.command=java +#set.JAVA_HOME=/home/jdk1.8.0_65 +#wrapper.java.command=%JAVA_HOME%/bin/java +wrapper.java.command.loglevel=INFO + +wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp +wrapper.java.classpath.1=./ +wrapper.java.classpath.2=../conf/ +wrapper.java.classpath.3=../lib/*.jar + +wrapper.java.library.path.1=../lib + +wrapper.java.additional.auto_bits=TRUE +#set the default parameters +wrapper.java.additional.1=-Xms512m +wrapper.java.additional.2=-Xmx1024m +wrapper.java.additional.3=-XX:PermSize=256m +wrapper.java.additional.4=-XX:MaxPermSize=512m +wrapper.java.additional.5=-Djava.net.preferIPv4Stack=true +wrapper.java.additional.6=-Dsun.lang.ClassLoader.allowArraySyntax=true + +# Initial Java Heap Size (in MB) +wrapper.java.initmemory=128 +# Maximum Java Heap Size (in MB) +wrapper.java.maxmemory=512 + +# Application parameters. Add parameters as needed starting from 1 +wrapper.app.parameter.1=org.springframework.boot.loader.JarLauncher +wrapper.app.parameter.2=--spring.config.location=../conf/application.properties +wrapper.app.parameter.3=--logging.config=../conf/logback.xml +wrapper.app.parameter.4=--logging.path=../logs + +wrapper.filter.trigger.1=java.lang.OutOfMemoryError +wrapper.filter.action.1=RESTART + +wrapper.console.format=PM +wrapper.console.loglevel=INFO + +wrapper.logfile=../logs/mq_YYYYMMDD.log +wrapper.logfile.rollmode=DATE +wrapper.logfile.format=LPTM +wrapper.logfile.loglevel=INFO +wrapper.logfile.maxsize=0 +wrapper.logfile.maxfiles=0 +wrapper.syslog.loglevel=NONE + +wrapper.ignore_sequence_gaps=TRUE +wrapper.pidfile.strict=TRUE + +wrapper.console.title=estore mq application + +wrapper.name=estore_mq +wrapper.displayname=estore mq application +wrapper.description=estore mq application +wrapper.ntservice.dependency.1= +wrapper.ntservice.starttype=AUTO_START +wrapper.ntservice.interactive=false diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/food-mq-2.0.0.jar b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/food-mq-2.0.0.jar new file mode 100644 index 0000000..9e7b08e Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/food-mq-2.0.0.jar differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-32.jnilib b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-32.jnilib new file mode 100644 index 0000000..ae75d31 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-32.jnilib differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-64.jnilib b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-64.jnilib new file mode 100644 index 0000000..e7d4102 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/libwrapper-macosx-universal-64.jnilib differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-32.dll b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-32.dll new file mode 100644 index 0000000..6aaa9c1 Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-32.dll differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-64.dll b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-64.dll new file mode 100644 index 0000000..81f11ce Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper-windows-x86-64.dll differ diff --git a/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper.jar b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper.jar new file mode 100644 index 0000000..70dc5ab Binary files /dev/null and b/food-mq/target/food-mq-2.0.0/food-mq-2.0.0/lib/wrapper.jar differ diff --git a/food-mq/target/maven-archiver/pom.properties b/food-mq/target/maven-archiver/pom.properties new file mode 100644 index 0000000..0574fd4 --- /dev/null +++ b/food-mq/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Dec 26 12:40:25 CST 2023 +version=2.0.0 +groupId=com.jwsaas +artifactId=food-mq diff --git a/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..221d3d1 --- /dev/null +++ b/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,43 @@ +com\jwsaas\config\MQMessageSender.class +com\jwsaas\config\RabbitMQConfig$2.class +com\jwsaas\RabbitConstant.class +com\jwsaas\config\RabbitMQConfig$1$2.class +com\jwsaas\config\RabbitMQConfig$2$2.class +com\jwsaas\mqtt\MqttClientExt$1.class +com\jwsaas\config\RabbitMQConfig$3$7.class +com\jwsaas\mqtt\MqttConfiguration.class +com\jwsaas\config\DubboSupport.class +com\jwsaas\config\RabbitMQConfig$3$9.class +com\jwsaas\config\RabbitMQConfig$4.class +com\jwsaas\config\RabbitMQConfig$9.class +com\jwsaas\config\RabbitMQConfig$3$4.class +com\jwsaas\config\ExpirationMessagePostProcessor.class +com\jwsaas\config\RabbitMQConfig$8$1.class +com\jwsaas\config\RabbitMQConfig$5$2.class +com\jwsaas\config\RabbitMQConfig$3$5.class +com\jwsaas\config\RabbitMQConfig$6.class +com\jwsaas\config\RabbitMQConfig$9$1.class +com\jwsaas\config\RabbitMQConfig$4$2.class +com\jwsaas\config\RabbitMQConfig$3.class +com\jwsaas\util\JSONException.class +com\jwsaas\config\RabbitMQConfig$3$2.class +com\jwsaas\config\RabbitMQConfig$3$1.class +com\jwsaas\util\JSONUtil$1.class +com\jwsaas\config\RabbitMQConfig$2$1.class +com\jwsaas\Constant.class +com\jwsaas\config\RabbitMQConfig$8.class +com\jwsaas\config\RabbitMQConfig$1$1.class +com\jwsaas\Application.class +com\jwsaas\config\RabbitMQConfig$1.class +com\jwsaas\config\RabbitMQConfig$3$8.class +com\jwsaas\mqtt\PushCallback.class +com\jwsaas\mqtt\Topic.class +com\jwsaas\config\RabbitMQConfig$5.class +com\jwsaas\config\RabbitMQConfig.class +com\jwsaas\util\JSONUtil.class +com\jwsaas\config\RabbitMQConfig$3$3.class +com\jwsaas\config\RabbitMQConfig$3$6.class +com\jwsaas\config\RabbitMQConfig$5$1.class +com\jwsaas\mqtt\MqttClientExt.class +com\jwsaas\config\RabbitMQConfig$4$1.class +com\jwsaas\config\RabbitMQConfig$7.class diff --git a/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..4dd9ef5 --- /dev/null +++ b/food-mq/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +E:\food\food\food-mq\src\main\java\com\jwsaas\config\DubboSupport.java +E:\food\food\food-mq\src\main\java\com\jwsaas\mqtt\MqttClientExt.java +E:\food\food\food-mq\src\main\java\com\jwsaas\RabbitConstant.java +E:\food\food\food-mq\src\main\java\com\jwsaas\util\JSONUtil.java +E:\food\food\food-mq\src\main\java\com\jwsaas\config\MQMessageSender.java +E:\food\food\food-mq\src\main\java\com\jwsaas\mqtt\Topic.java +E:\food\food\food-mq\src\main\java\com\jwsaas\config\RabbitMQConfig.java +E:\food\food\food-mq\src\main\java\com\jwsaas\util\JSONException.java +E:\food\food\food-mq\src\main\java\com\jwsaas\mqtt\MqttConfiguration.java +E:\food\food\food-mq\src\main\java\com\jwsaas\Constant.java +E:\food\food\food-mq\src\main\java\com\jwsaas\mqtt\PushCallback.java +E:\food\food\food-mq\src\main\java\com\jwsaas\Application.java +E:\food\food\food-mq\src\main\java\com\jwsaas\config\ExpirationMessagePostProcessor.java diff --git a/food-mq/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/food-mq/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29