提交 5858b2e4 authored 作者: wangqiang's avatar wangqiang

192.168.124.29

上级 3b98ae24
...@@ -325,7 +325,7 @@ ...@@ -325,7 +325,7 @@
<configuration> <configuration>
<archive> <archive>
<manifestEntries> <manifestEntries>
<Implementation-Title>PriusisIot Gateway</Implementation-Title> <Implementation-Title>apq-pc-client</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version> <Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries> </manifestEntries>
</archive> </archive>
......
...@@ -41,17 +41,17 @@ ...@@ -41,17 +41,17 @@
<file> <file>
<source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source> <source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>
<outputDirectory>lib</outputDirectory> <outputDirectory>lib</outputDirectory>
<destName>${pkg.name}.jar</destName> <destName>apq-pc-client.jar</destName>
</file> </file>
<file> <file>
<source>${pkg.win.dist}/service.exe</source> <source>${pkg.win.dist}/service.exe</source>
<outputDirectory/> <outputDirectory/>
<destName>${pkg.name}.exe</destName> <destName>apq-pc-client.exe</destName>
</file> </file>
<file> <file>
<source>${pkg.win.dist}/service.xml</source> <source>${pkg.win.dist}/service.xml</source>
<outputDirectory/> <outputDirectory/>
<destName>${pkg.name}.xml</destName> <destName>apq-pc-client.xml</destName>
<lineEnding>windows</lineEnding> <lineEnding>windows</lineEnding>
</file> </file>
<file> <file>
......
export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@" export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@"
export LOG_FILENAME=${pkg.name}.out export LOG_FILENAME=apq-pc-client.out
export LOADER_PATH=${pkg.installFolder}/conf export LOADER_PATH=${pkg.installFolder}/conf
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration> <!DOCTYPE configuration>
<configuration> <configuration>
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<springProperty scop="context" name="CONSOLE_LOG_PATH" source="CONSOLE_LOG_PATH" defaultValue="/apps/logs"/>
<property name="log.path" value="${CONSOLE_LOG_PATH}/${spring.application.name}" />
<appender name="fileLogAppender" <appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${pkg.logFolder}/${pkg.name}.log</file> <file>${log.path}/info.log</file>
<rollingPolicy <rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
...@@ -20,6 +23,10 @@ ...@@ -20,6 +23,10 @@
<logger name="org.priusis" level="INFO" /> <logger name="org.priusis" level="INFO" />
<logger name="org.eclipse.milo" level="INFO" /> <logger name="org.eclipse.milo" level="INFO" />
<logger name="org.eclipse.paho" level="INFO" /> <logger name="org.eclipse.paho" level="INFO" />
<logger name="springfox" level="ERROR"/>
<logger name="org" level="ERROR"/>
<logger name="com.netflix" level="ERROR"/>
<logger name="com.alibaba.nacos" level="ERROR"/>
<root level="INFO"> <root level="INFO">
<appender-ref ref="fileLogAppender"/> <appender-ref ref="fileLogAppender"/>
......
...@@ -669,9 +669,9 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -669,9 +669,9 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
deviceInfo = StrUtil.format(deviceInfo, mac); deviceInfo = StrUtil.format(deviceInfo, mac);
String remoteDeviceVoJson = HttpUtil.get(gateway + deviceInfo); String remoteDeviceVoJson = HttpUtil.get(gateway + deviceInfo);
RemoteDeviceVo remoteDeviceVo = JSONUtil.toBean(remoteDeviceVoJson, RemoteDeviceVo.class); RemoteDeviceVoResult remoteDeviceVo = JSONUtil.toBean(remoteDeviceVoJson, RemoteDeviceVoResult.class);
MqttClientSecurityConfiguration mqttClientSecurityConfiguration = new MqttClientSecurityConfiguration(); MqttClientSecurityConfiguration mqttClientSecurityConfiguration = new MqttClientSecurityConfiguration();
mqttClientSecurityConfiguration.setAccessToken(remoteDeviceVo.getSecretKey()); mqttClientSecurityConfiguration.setAccessToken(remoteDeviceVo.getData().getSecretKey());
return mqttClientSecurityConfiguration; return mqttClientSecurityConfiguration;
} catch (Exception e) { } catch (Exception e) {
...@@ -679,4 +679,11 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -679,4 +679,11 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} }
return null; return null;
} }
public static void main(String[] args) throws Exception {
NetworkIF networkIF = new NetworkIF();
networkIF.setNetworkInterface(NetworkInterface.getByInetAddress(InetAddress.getLocalHost()));
String mac = networkIF.getMacaddr();
System.out.println(mac);
}
} }
package com.priusis.client.service.core;
import lombok.Data;
@Data
public class RemoteDeviceVoResult {
private Integer code;
private String msg;
private RemoteDeviceVo data;
}
apq: apq:
iot-gateway: 192.168.124.19:7002 iot-gateway: 192.168.124.19:7002
PC_HOST: 192.168.124.29
...@@ -5,7 +5,7 @@ server: ...@@ -5,7 +5,7 @@ server:
spring: spring:
application: application:
name: haikang-client name: apq-pc-client
profiles: profiles:
active: dev active: dev
......
[Unit] [Unit]
Description=${pkg.name} Description=apq-pc-client
After=syslog.target After=syslog.target
[Service] [Service]
User=${pkg.user} User=${pkg.user}
ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar ExecStart=${pkg.installFolder}/bin/apq-pc-client.jar
SuccessExitStatus=143 SuccessExitStatus=143
[Install] [Install]
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
chown -R ${pkg.user}: ${pkg.logFolder} chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder} chown -R ${pkg.user}: ${pkg.installFolder}
update-rc.d ${pkg.name} defaults update-rc.d apq-pc-client defaults
#!/bin/sh #!/bin/sh
update-rc.d -f ${pkg.name} remove update-rc.d -f apq-pc-client remove
#!/bin/sh #!/bin/sh
if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then if [ -e /var/run/apq-pc-client/apq-pc-client.pid ]; then
service ${pkg.name} stop service apq-pc-client stop
fi fi
...@@ -5,5 +5,5 @@ chown -R ${pkg.user}: ${pkg.installFolder} ...@@ -5,5 +5,5 @@ chown -R ${pkg.user}: ${pkg.installFolder}
if [ $1 -eq 1 ] ; then if [ $1 -eq 1 ] ; then
# Initial installation # Initial installation
systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || : systemctl --no-reload enable apq-pc-client.service >/dev/null 2>&1 || :
fi fi
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
if [ $1 -ge 1 ] ; then if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall # Package upgrade, not uninstall
systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || : systemctl try-restart apq-pc-client.service >/dev/null 2>&1 || :
fi fi
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
if [ $1 -eq 0 ] ; then if [ $1 -eq 0 ] ; then
# Package removal, not upgrade # Package removal, not upgrade
systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || : systemctl --no-reload disable --now apq-pc-client.service > /dev/null 2>&1 || :
fi fi
...@@ -68,8 +68,8 @@ IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED ...@@ -68,8 +68,8 @@ IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
:JAVA_INSTALLED :JAVA_INSTALLED
@ECHO Java 1.8 found! @ECHO Java 1.8 found!
@ECHO Installing ${pkg.name} ... @ECHO Installing apq-pc-client ...
%~dp0${pkg.name}.exe install %~dp0apq-pc-client.exe install
@ECHO DONE. @ECHO DONE.
......
<service> <service>
<id>${pkg.name}</id> <id>apq-pc-client</id>
<name>${project.name}</name> <name>${project.name}</name>
<description>${project.description}</description> <description>${project.description}</description>
<workingdirectory>%BASE%\conf</workingdirectory> <workingdirectory>%BASE%\conf</workingdirectory>
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
<executable>java</executable> <executable>java</executable>
<startargument>-Dplatform=windows</startargument> <startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument> <startargument>-jar</startargument>
<startargument>%BASE%\lib\${pkg.name}.jar</startargument> <startargument>%BASE%\lib\apq-pc-client.jar</startargument>
</service> </service>
@ECHO OFF @ECHO OFF
@ECHO Stopping ${pkg.name} ... @ECHO Stopping apq-pc-client ...
net stop ${pkg.name} net stop apq-pc-client
@ECHO Uninstalling ${pkg.name} ... @ECHO Uninstalling apq-pc-client ...
%~dp0${pkg.name}.exe uninstall %~dp0apq-pc-client.exe uninstall
@ECHO DONE. @ECHO DONE.
\ No newline at end of file
...@@ -86,228 +86,81 @@ ...@@ -86,228 +86,81 @@
<directory>${project.basedir}/src/main/resources</directory> <directory>${project.basedir}/src/main/resources</directory>
</resource> </resource>
</resources> </resources>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<target>${java.version}</target> <target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>copy</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy</goal> <goal>shade</goal>
</goals> </goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<classifier>bin</classifier>
<type>exe</type>
<destFileName>service.exe</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${pkg.win.dist}</outputDirectory>
</configuration>
</execution> </execution>
</executions> </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-service-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/conf</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters> <filters>
<filter>src/main/filters/unix.properties</filter> <filter>
</filters> <artifact>*:*</artifact>
</configuration>
</execution>
<execution>
<id>copy-win-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes> <excludes>
<exclude>logback.xml</exclude> <exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes> </excludes>
<filtering>false</filtering> </filter>
</resource>
<resource>
<directory>src/main/conf</directory>
<excludes>
<exclude>pi-gateway.conf</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/control</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/control</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/unix.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-windows-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/windows</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters> </filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>launch4j-maven-plugin</artifactId>
<configuration> <version>1.7</version>
<archive>
<manifestEntries>
<Implementation-Title>PriusisIot Gateway</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>boot</classifier>
<layout>ZIP</layout>
<executable>true</executable>
<excludeDevtools>true</excludeDevtools>
<embeddedLaunchScriptProperties>
<confFolder>${pkg.installFolder}/conf</confFolder>
<logFolder>${pkg.unixLogFolder}</logFolder>
<logFilename>${pkg.name}.out</logFilename>
<initInfoProvides>${pkg.name}</initInfoProvides>
</embeddedLaunchScriptProperties>
</configuration>
<executions> <executions>
<!-- GUI exe -->
<execution> <execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals> <goals>
<goal>repackage</goal> <goal>launch4j</goal>
</goals> </goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration> <configuration>
<finalName>${pkg.name}</finalName> <headerType>gui</headerType>
<descriptors> <outfile>target/apq-pc-control.exe</outfile>
<descriptor>src/main/assembly/windows.xml</descriptor> <jar>target/${project.artifactId}-${project.version}-shaded.jar</jar>
</descriptors> <errTitle>App Err</errTitle>
<classPath>
<mainClass>com.priusis.ApqInfoApplication</mainClass>
</classPath>
<icon>src/main/resources/icons/favicon.ico</icon>
<jre>
<minVersion>1.8.0</minVersion>
<maxVersion>1.9.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Desc</fileDescription>
<copyright>C</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Product</productName>
<internalName>Product</internalName>
<originalFilename>App.exe</originalFilename>
</versionInfo>
</configuration> </configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
......
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>
<formats>
<format>zip</format>
</formats>
<!-- Workaround to create logs directory -->
<fileSets>
<fileSet>
<directory>${pkg.win.dist}</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<lineEnding>windows</lineEnding>
<excludes>
<exclude>*.der</exclude>
<exclude>*.cer</exclude>
<exclude>*.pfx</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>*.der</include>
<include>*.cer</include>
<include>*.pfx</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>
<outputDirectory>lib</outputDirectory>
<destName>${pkg.name}.jar</destName>
</file>
<file>
<source>${pkg.win.dist}/service.exe</source>
<outputDirectory/>
<destName>${pkg.name}.exe</destName>
</file>
<file>
<source>${pkg.win.dist}/service.xml</source>
<outputDirectory/>
<destName>${pkg.name}.xml</destName>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/install.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/uninstall.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
</files>
</assembly>
export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@"
export LOG_FILENAME=${pkg.name}.out
export LOADER_PATH=${pkg.installFolder}/conf
pkg.logFolder=${pkg.unixLogFolder}
\ No newline at end of file
pkg.logFolder=${BASE}\\logs
pkg.winWrapperLogFolder=%BASE%\\logs
spring:
application:
name: apq-pc-control
server: server:
# Server bind address # Server bind address
address: "0.0.0.0" address: "0.0.0.0"
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration> <!DOCTYPE configuration>
<configuration> <configuration>
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<springProperty scop="context" name="CONSOLE_LOG_PATH" source="CONSOLE_LOG_PATH" defaultValue="/apps/logs"/>
<property name="log.path" value="${CONSOLE_LOG_PATH}/${spring.application.name}" />
<appender name="fileLogAppender" <appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${pkg.logFolder}/${pkg.name}.log</file> <file>${log.path}/info.log</file>
<rollingPolicy <rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
...@@ -20,6 +23,10 @@ ...@@ -20,6 +23,10 @@
<logger name="org.priusis" level="INFO" /> <logger name="org.priusis" level="INFO" />
<logger name="org.eclipse.milo" level="INFO" /> <logger name="org.eclipse.milo" level="INFO" />
<logger name="org.eclipse.paho" level="INFO" /> <logger name="org.eclipse.paho" level="INFO" />
<logger name="springfox" level="ERROR"/>
<logger name="org" level="ERROR"/>
<logger name="com.netflix" level="ERROR"/>
<logger name="com.alibaba.nacos" level="ERROR"/>
<root level="INFO"> <root level="INFO">
<appender-ref ref="fileLogAppender"/> <appender-ref ref="fileLogAppender"/>
......
[Unit]
Description=${pkg.name}
After=syslog.target
[Service]
User=${pkg.user}
ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
update-rc.d ${pkg.name} defaults
#!/bin/sh
update-rc.d -f ${pkg.name} remove
#!/bin/sh
if ! getent group ${pkg.user} >/dev/null; then
addgroup --system ${pkg.user}
fi
if ! getent passwd ${pkg.user} >/dev/null; then
adduser --quiet \
--system \
--ingroup ${pkg.user} \
--quiet \
--disabled-login \
--disabled-password \
--home ${pkg.installFolder} \
--no-create-home \
-gecos "Priusisiot application" \
${pkg.user}
fi
#!/bin/sh
if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then
service ${pkg.name} stop
fi
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}
getent passwd ${pkg.user} >/dev/null || \
useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \
-c "Priusisiot application"
#!/bin/sh
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
fi
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Detecting Java version installed.
:CHECK_JAVA_64
@ECHO Detecting if it is 64 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF NOT "%JRE_PATH2%" == "" GOTO JAVA_INSTALLED
:CHECK_JAVA_32
@ECHO Detecting if it is 32 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
:JAVA_INSTALLED
@ECHO Java 1.8 found!
@ECHO Installing ${pkg.name} ...
%~dp0${pkg.name}.exe install
@ECHO DONE.
GOTO END
:JAVA_NOT_INSTALLED
@ECHO Java 1.8 or above is not installed
@ECHO Please go to https://java.com/ and install Java. Then retry installation.
PAUSE
GOTO END
:END
<service>
<id>${pkg.name}</id>
<name>${project.name}</name>
<description>${project.description}</description>
<workingdirectory>%BASE%\conf</workingdirectory>
<logpath>${pkg.winWrapperLogFolder}</logpath>
<logmode>rotate</logmode>
<env name="LOADER_PATH" value="%BASE%\conf" />
<executable>java</executable>
<startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument>
<startargument>%BASE%\lib\${pkg.name}.jar</startargument>
</service>
@ECHO OFF
@ECHO Stopping ${pkg.name} ...
net stop ${pkg.name}
@ECHO Uninstalling ${pkg.name} ...
%~dp0${pkg.name}.exe uninstall
@ECHO DONE.
\ No newline at end of file
...@@ -80,228 +80,81 @@ ...@@ -80,228 +80,81 @@
<directory>${project.basedir}/src/main/resources</directory> <directory>${project.basedir}/src/main/resources</directory>
</resource> </resource>
</resources> </resources>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<target>${java.version}</target> <target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>copy</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy</goal> <goal>shade</goal>
</goals> </goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<classifier>bin</classifier>
<type>exe</type>
<destFileName>service.exe</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${pkg.win.dist}</outputDirectory>
</configuration>
</execution> </execution>
</executions> </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-service-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/conf</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters> <filters>
<filter>src/main/filters/unix.properties</filter> <filter>
</filters> <artifact>*:*</artifact>
</configuration>
</execution>
<execution>
<id>copy-win-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes> <excludes>
<exclude>logback.xml</exclude> <exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes> </excludes>
<filtering>false</filtering> </filter>
</resource>
<resource>
<directory>src/main/conf</directory>
<excludes>
<exclude>pi-gateway.conf</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/control</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/control</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/unix.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-windows-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/windows</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters> </filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>launch4j-maven-plugin</artifactId>
<configuration> <version>1.7</version>
<archive>
<manifestEntries>
<Implementation-Title>PriusisIot Gateway</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>boot</classifier>
<layout>ZIP</layout>
<executable>true</executable>
<excludeDevtools>true</excludeDevtools>
<embeddedLaunchScriptProperties>
<confFolder>${pkg.installFolder}/conf</confFolder>
<logFolder>${pkg.unixLogFolder}</logFolder>
<logFilename>${pkg.name}.out</logFilename>
<initInfoProvides>${pkg.name}</initInfoProvides>
</embeddedLaunchScriptProperties>
</configuration>
<executions> <executions>
<!-- GUI exe -->
<execution> <execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals> <goals>
<goal>repackage</goal> <goal>launch4j</goal>
</goals> </goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration> <configuration>
<finalName>${pkg.name}</finalName> <headerType>gui</headerType>
<descriptors> <outfile>target/apq-pc-info.exe</outfile>
<descriptor>src/main/assembly/windows.xml</descriptor> <jar>target/${project.artifactId}-${project.version}-shaded.jar</jar>
</descriptors> <errTitle>App Err</errTitle>
<classPath>
<mainClass>com.priusis.ApqInfoApplication</mainClass>
</classPath>
<icon>src/main/resources/icons/favicon.ico</icon>
<jre>
<minVersion>1.8.0</minVersion>
<maxVersion>1.9.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Desc</fileDescription>
<copyright>C</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Product</productName>
<internalName>Product</internalName>
<originalFilename>App.exe</originalFilename>
</versionInfo>
</configuration> </configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
......
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>
<formats>
<format>zip</format>
</formats>
<!-- Workaround to create logs directory -->
<fileSets>
<fileSet>
<directory>${pkg.win.dist}</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<lineEnding>windows</lineEnding>
<excludes>
<exclude>*.der</exclude>
<exclude>*.cer</exclude>
<exclude>*.pfx</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>*.der</include>
<include>*.cer</include>
<include>*.pfx</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>
<outputDirectory>lib</outputDirectory>
<destName>${pkg.name}.jar</destName>
</file>
<file>
<source>${pkg.win.dist}/service.exe</source>
<outputDirectory/>
<destName>${pkg.name}.exe</destName>
</file>
<file>
<source>${pkg.win.dist}/service.xml</source>
<outputDirectory/>
<destName>${pkg.name}.xml</destName>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/install.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/uninstall.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
</files>
</assembly>
export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@"
export LOG_FILENAME=${pkg.name}.out
export LOADER_PATH=${pkg.installFolder}/conf
pkg.logFolder=${pkg.unixLogFolder}
\ No newline at end of file
pkg.logFolder=${BASE}\\logs
pkg.winWrapperLogFolder=%BASE%\\logs
spring:
application:
name: apq-pc-info
server: server:
# Server bind address # Server bind address
address: "0.0.0.0" address: "0.0.0.0"
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration> <!DOCTYPE configuration>
<configuration> <configuration>
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<springProperty scop="context" name="CONSOLE_LOG_PATH" source="CONSOLE_LOG_PATH" defaultValue="/apps/logs"/>
<property name="log.path" value="${CONSOLE_LOG_PATH}/${spring.application.name}" />
<appender name="fileLogAppender" <appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${pkg.logFolder}/${pkg.name}.log</file> <file>${log.path}/info.log</file>
<rollingPolicy <rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
...@@ -20,6 +23,10 @@ ...@@ -20,6 +23,10 @@
<logger name="org.priusis" level="INFO" /> <logger name="org.priusis" level="INFO" />
<logger name="org.eclipse.milo" level="INFO" /> <logger name="org.eclipse.milo" level="INFO" />
<logger name="org.eclipse.paho" level="INFO" /> <logger name="org.eclipse.paho" level="INFO" />
<logger name="springfox" level="ERROR"/>
<logger name="org" level="ERROR"/>
<logger name="com.netflix" level="ERROR"/>
<logger name="com.alibaba.nacos" level="ERROR"/>
<root level="INFO"> <root level="INFO">
<appender-ref ref="fileLogAppender"/> <appender-ref ref="fileLogAppender"/>
......
[Unit]
Description=${pkg.name}
After=syslog.target
[Service]
User=${pkg.user}
ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
update-rc.d ${pkg.name} defaults
#!/bin/sh
update-rc.d -f ${pkg.name} remove
#!/bin/sh
if ! getent group ${pkg.user} >/dev/null; then
addgroup --system ${pkg.user}
fi
if ! getent passwd ${pkg.user} >/dev/null; then
adduser --quiet \
--system \
--ingroup ${pkg.user} \
--quiet \
--disabled-login \
--disabled-password \
--home ${pkg.installFolder} \
--no-create-home \
-gecos "Priusisiot application" \
${pkg.user}
fi
#!/bin/sh
if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then
service ${pkg.name} stop
fi
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}
getent passwd ${pkg.user} >/dev/null || \
useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \
-c "Priusisiot application"
#!/bin/sh
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
fi
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Detecting Java version installed.
:CHECK_JAVA_64
@ECHO Detecting if it is 64 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF NOT "%JRE_PATH2%" == "" GOTO JAVA_INSTALLED
:CHECK_JAVA_32
@ECHO Detecting if it is 32 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
:JAVA_INSTALLED
@ECHO Java 1.8 found!
@ECHO Installing ${pkg.name} ...
%~dp0${pkg.name}.exe install
@ECHO DONE.
GOTO END
:JAVA_NOT_INSTALLED
@ECHO Java 1.8 or above is not installed
@ECHO Please go to https://java.com/ and install Java. Then retry installation.
PAUSE
GOTO END
:END
<service>
<id>${pkg.name}</id>
<name>${project.name}</name>
<description>${project.description}</description>
<workingdirectory>%BASE%\conf</workingdirectory>
<logpath>${pkg.winWrapperLogFolder}</logpath>
<logmode>rotate</logmode>
<env name="LOADER_PATH" value="%BASE%\conf" />
<executable>java</executable>
<startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument>
<startargument>%BASE%\lib\${pkg.name}.jar</startargument>
</service>
@ECHO OFF
@ECHO Stopping ${pkg.name} ...
net stop ${pkg.name}
@ECHO Uninstalling ${pkg.name} ...
%~dp0${pkg.name}.exe uninstall
@ECHO DONE.
\ No newline at end of file
...@@ -76,228 +76,81 @@ ...@@ -76,228 +76,81 @@
<directory>${project.basedir}/src/main/resources</directory> <directory>${project.basedir}/src/main/resources</directory>
</resource> </resource>
</resources> </resources>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<target>${java.version}</target> <target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>copy</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>copy</goal> <goal>shade</goal>
</goals> </goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<classifier>bin</classifier>
<type>exe</type>
<destFileName>service.exe</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${pkg.win.dist}</outputDirectory>
</configuration>
</execution> </execution>
</executions> </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-service-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/conf</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters> <filters>
<filter>src/main/filters/unix.properties</filter> <filter>
</filters> <artifact>*:*</artifact>
</configuration>
</execution>
<execution>
<id>copy-win-conf</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes> <excludes>
<exclude>logback.xml</exclude> <exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes> </excludes>
<filtering>false</filtering> </filter>
</resource>
<resource>
<directory>src/main/conf</directory>
<excludes>
<exclude>pi-gateway.conf</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/control</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/control</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/unix.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>copy-windows-control</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${pkg.win.dist}</outputDirectory>
<resources>
<resource>
<directory>src/main/scripts/windows</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/windows.properties</filter>
</filters> </filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>launch4j-maven-plugin</artifactId>
<configuration> <version>1.7</version>
<archive>
<manifestEntries>
<Implementation-Title>PriusisIot Gateway</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>boot</classifier>
<layout>ZIP</layout>
<executable>true</executable>
<excludeDevtools>true</excludeDevtools>
<embeddedLaunchScriptProperties>
<confFolder>${pkg.installFolder}/conf</confFolder>
<logFolder>${pkg.unixLogFolder}</logFolder>
<logFilename>${pkg.name}.out</logFilename>
<initInfoProvides>${pkg.name}</initInfoProvides>
</embeddedLaunchScriptProperties>
</configuration>
<executions> <executions>
<!-- GUI exe -->
<execution> <execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals> <goals>
<goal>repackage</goal> <goal>launch4j</goal>
</goals> </goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration> <configuration>
<finalName>${pkg.name}</finalName> <headerType>gui</headerType>
<descriptors> <outfile>target/apq-pc-register.exe</outfile>
<descriptor>src/main/assembly/windows.xml</descriptor> <jar>target/${project.artifactId}-${project.version}-shaded.jar</jar>
</descriptors> <errTitle>App Err</errTitle>
<classPath>
<mainClass>com.priusis.ApqRegisterApplication</mainClass>
</classPath>
<icon>src/main/resources/icons/favicon.ico</icon>
<jre>
<minVersion>1.8.0</minVersion>
<maxVersion>1.9.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Desc</fileDescription>
<copyright>C</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Product</productName>
<internalName>Product</internalName>
<originalFilename>App.exe</originalFilename>
</versionInfo>
</configuration> </configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
......
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>
<formats>
<format>zip</format>
</formats>
<!-- Workaround to create logs directory -->
<fileSets>
<fileSet>
<directory>${pkg.win.dist}</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<lineEnding>windows</lineEnding>
<excludes>
<exclude>*.der</exclude>
<exclude>*.cer</exclude>
<exclude>*.pfx</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${pkg.win.dist}/conf</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>*.der</include>
<include>*.cer</include>
<include>*.pfx</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>
<outputDirectory>lib</outputDirectory>
<destName>${pkg.name}.jar</destName>
</file>
<file>
<source>${pkg.win.dist}/service.exe</source>
<outputDirectory/>
<destName>${pkg.name}.exe</destName>
</file>
<file>
<source>${pkg.win.dist}/service.xml</source>
<outputDirectory/>
<destName>${pkg.name}.xml</destName>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/install.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
<file>
<source>${pkg.win.dist}/uninstall.bat</source>
<outputDirectory/>
<lineEnding>windows</lineEnding>
</file>
</files>
</assembly>
export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@"
export LOG_FILENAME=${pkg.name}.out
export LOADER_PATH=${pkg.installFolder}/conf
pkg.logFolder=${pkg.unixLogFolder}
\ No newline at end of file
pkg.logFolder=${BASE}\\logs
pkg.winWrapperLogFolder=%BASE%\\logs
spring:
application:
name: apq-pc-register
server: server:
# Server bind address # Server bind address
address: "0.0.0.0" address: "0.0.0.0"
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration> <!DOCTYPE configuration>
<configuration> <configuration>
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<springProperty scop="context" name="CONSOLE_LOG_PATH" source="CONSOLE_LOG_PATH" defaultValue="/apps/logs"/>
<property name="log.path" value="${CONSOLE_LOG_PATH}/${spring.application.name}" />
<appender name="fileLogAppender" <appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${pkg.logFolder}/${pkg.name}.log</file> <file>${log.path}/info.log</file>
<rollingPolicy <rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${pkg.logFolder}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
...@@ -20,6 +23,10 @@ ...@@ -20,6 +23,10 @@
<logger name="org.priusis" level="INFO" /> <logger name="org.priusis" level="INFO" />
<logger name="org.eclipse.milo" level="INFO" /> <logger name="org.eclipse.milo" level="INFO" />
<logger name="org.eclipse.paho" level="INFO" /> <logger name="org.eclipse.paho" level="INFO" />
<logger name="springfox" level="ERROR"/>
<logger name="org" level="ERROR"/>
<logger name="com.netflix" level="ERROR"/>
<logger name="com.alibaba.nacos" level="ERROR"/>
<root level="INFO"> <root level="INFO">
<appender-ref ref="fileLogAppender"/> <appender-ref ref="fileLogAppender"/>
......
[Unit]
Description=${pkg.name}
After=syslog.target
[Service]
User=${pkg.user}
ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
update-rc.d ${pkg.name} defaults
#!/bin/sh
update-rc.d -f ${pkg.name} remove
#!/bin/sh
if ! getent group ${pkg.user} >/dev/null; then
addgroup --system ${pkg.user}
fi
if ! getent passwd ${pkg.user} >/dev/null; then
adduser --quiet \
--system \
--ingroup ${pkg.user} \
--quiet \
--disabled-login \
--disabled-password \
--home ${pkg.installFolder} \
--no-create-home \
-gecos "Priusisiot application" \
${pkg.user}
fi
#!/bin/sh
if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then
service ${pkg.name} stop
fi
#!/bin/sh
chown -R ${pkg.user}: ${pkg.logFolder}
chown -R ${pkg.user}: ${pkg.installFolder}
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :
fi
#!/bin/sh
getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}
getent passwd ${pkg.user} >/dev/null || \
useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \
-c "Priusisiot application"
#!/bin/sh
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
fi
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Detecting Java version installed.
:CHECK_JAVA_64
@ECHO Detecting if it is 64 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF NOT "%JRE_PATH2%" == "" GOTO JAVA_INSTALLED
:CHECK_JAVA_32
@ECHO Detecting if it is 32 bit machine
set KEY_NAME="HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment"
set VALUE_NAME=CurrentVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@ECHO CurrentVersion %ValueValue%
SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
SET VALUE_NAME=JavaHome
if defined ValueName (
FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName2=%%A
set ValueType2=%%B
set JRE_PATH2=%%C
if defined ValueName2 (
set ValueName = %ValueName2%
set ValueType = %ValueType2%
set ValueValue = %JRE_PATH2%
)
)
)
IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
:JAVA_INSTALLED
@ECHO Java 1.8 found!
@ECHO Installing ${pkg.name} ...
%~dp0${pkg.name}.exe install
@ECHO DONE.
GOTO END
:JAVA_NOT_INSTALLED
@ECHO Java 1.8 or above is not installed
@ECHO Please go to https://java.com/ and install Java. Then retry installation.
PAUSE
GOTO END
:END
<service>
<id>${pkg.name}</id>
<name>${project.name}</name>
<description>${project.description}</description>
<workingdirectory>%BASE%\conf</workingdirectory>
<logpath>${pkg.winWrapperLogFolder}</logpath>
<logmode>rotate</logmode>
<env name="LOADER_PATH" value="%BASE%\conf" />
<executable>java</executable>
<startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument>
<startargument>%BASE%\lib\${pkg.name}.jar</startargument>
</service>
@ECHO OFF
@ECHO Stopping ${pkg.name} ...
net stop ${pkg.name}
@ECHO Uninstalling ${pkg.name} ...
%~dp0${pkg.name}.exe uninstall
@ECHO DONE.
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论