傅行帆 před 6 roky
rodič
revize
0770660efe

+ 19
- 0
CODE/smart-community/app-api/pom.xml Zobrazit soubor

@@ -218,6 +218,25 @@
218 218
 					</compilerArguments>
219 219
 				</configuration>
220 220
 			</plugin>
221
+			<!--服务化打包工具-->
222
+			<plugin>
223
+				<groupId>org.apache.maven.plugins</groupId>
224
+				<artifactId>maven-assembly-plugin</artifactId>
225
+				<configuration>
226
+					<descriptors>
227
+						<descriptor>src/main/assembly/assembly.xml</descriptor>
228
+					</descriptors>
229
+				</configuration>
230
+				<executions>
231
+					<execution>
232
+						<id>make-assembly</id>
233
+						<phase>package</phase>
234
+						<goals>
235
+							<goal>single</goal>
236
+						</goals>
237
+					</execution>
238
+				</executions>
239
+			</plugin>
221 240
 		</plugins>
222 241
 	</build>
223 242
 

+ 30
- 0
CODE/smart-community/app-api/src/main/assembly/assembly.xml Zobrazit soubor

@@ -0,0 +1,30 @@
1
+<assembly>
2
+    <id>assembly</id>
3
+    <formats>
4
+        <format>tar.gz</format>
5
+    </formats>
6
+    <includeBaseDirectory>true</includeBaseDirectory>
7
+    <fileSets>
8
+        <fileSet>
9
+            <directory>src/main/assembly/bin</directory>
10
+            <outputDirectory>bin</outputDirectory>
11
+            <fileMode>0755</fileMode>
12
+        </fileSet>
13
+        <fileSet>
14
+            <directory>target/classes</directory>
15
+            <outputDirectory>conf</outputDirectory>
16
+            <includes>
17
+                <include>META-INF/**</include>
18
+                <include>*.yml</include>
19
+                <include>conf/**</include>
20
+            </includes>
21
+            <fileMode>0755</fileMode>
22
+        </fileSet>
23
+    </fileSets>
24
+    <dependencySets>
25
+        <dependencySet>
26
+            <useProjectArtifact>true</useProjectArtifact>
27
+            <outputDirectory>lib</outputDirectory>
28
+        </dependencySet>
29
+    </dependencySets>
30
+</assembly>

+ 86
- 0
CODE/smart-community/app-api/src/main/assembly/bin/start.sh Zobrazit soubor

@@ -0,0 +1,86 @@
1
+#!/bin/bash
2
+
3
+SERVER_NAME='app-api'
4
+# jar名称
5
+JAR_NAME='app-api-0.0.1.jar'
6
+cd `dirname $0`
7
+BIN_DIR=`pwd`
8
+cd ..
9
+DEPLOY_DIR=`pwd`
10
+CONF_DIR=$DEPLOY_DIR/conf
11
+# 获取应用的端口号
12
+SERVER_PORT=`sed -nr '/port: [0-9]+/ s/.*port: +([0-9]+).*/\1/p' conf/bootstrap.yml`
13
+
14
+PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
15
+if [ "$1" = "status" ]; then
16
+    if [ -n "$PIDS" ]; then
17
+        echo "The $SERVER_NAME is running...!"
18
+        echo "PID: $PIDS"
19
+        exit 0
20
+    else
21
+        echo "The $SERVER_NAME is stopped"
22
+        exit 0
23
+    fi
24
+fi
25
+
26
+if [ -n "$PIDS" ]; then
27
+    echo "ERROR: The $SERVER_NAME already started!"
28
+    echo "PID: $PIDS"
29
+    exit 1
30
+fi
31
+
32
+if [ -n "$SERVER_PORT" ]; then
33
+    SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
34
+    if [ $SERVER_PORT_COUNT -gt 0 ]; then
35
+        echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
36
+        exit 1
37
+    fi
38
+fi
39
+
40
+LOGS_DIR=$DEPLOY_DIR/logs
41
+if [ ! -d $LOGS_DIR ]; then
42
+    mkdir $LOGS_DIR
43
+fi
44
+STDOUT_FILE=$LOGS_DIR/stdout.log
45
+
46
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
47
+JAVA_DEBUG_OPTS=""
48
+if [ "$1" = "debug" ]; then
49
+    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
50
+fi
51
+
52
+JAVA_JMX_OPTS=""
53
+if [ "$1" = "jmx" ]; then
54
+    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
55
+fi
56
+
57
+JAVA_MEM_OPTS=""
58
+BITS=`java -version 2>&1 | grep -i 64-bit`
59
+if [ -n "$BITS" ]; then
60
+    JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
61
+else
62
+    JAVA_MEM_OPTS=" -server -Xms512m -Xmx512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
63
+fi
64
+
65
+CONFIG_FILES=" -Dspring.config.location=$CONF_DIR/ "
66
+echo -e "Starting the $SERVER_NAME ..."
67
+nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/lib/$JAR_NAME > $STDOUT_FILE 2>&1 &
68
+
69
+COUNT=0
70
+while [ $COUNT -lt 1 ]; do
71
+    echo -e ".\c"
72
+    sleep 1
73
+    if [ -n "$SERVER_PORT" ]; then
74
+        COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
75
+    else
76
+        COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
77
+    fi
78
+    if [ $COUNT -gt 0 ]; then
79
+        break
80
+    fi
81
+done
82
+
83
+echo "OK!"
84
+PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
85
+echo "PID: $PIDS"
86
+echo "STDOUT: $STDOUT_FILE"

+ 19
- 1
CODE/smart-community/mq-message/pom.xml Zobrazit soubor

@@ -268,8 +268,26 @@
268 268
 					</compilerArguments>
269 269
 				</configuration>
270 270
 			</plugin>
271
+			<!--服务化打包工具-->
272
+			<plugin>
273
+				<groupId>org.apache.maven.plugins</groupId>
274
+				<artifactId>maven-assembly-plugin</artifactId>
275
+				<configuration>
276
+					<descriptors>
277
+						<descriptor>src/main/assembly/assembly.xml</descriptor>
278
+					</descriptors>
279
+				</configuration>
280
+				<executions>
281
+					<execution>
282
+						<id>make-assembly</id>
283
+						<phase>package</phase>
284
+						<goals>
285
+							<goal>single</goal>
286
+						</goals>
287
+					</execution>
288
+				</executions>
289
+			</plugin>
271 290
 		</plugins>
272 291
 	</build>
273 292
 
274
-
275 293
 </project>

+ 30
- 0
CODE/smart-community/mq-message/src/main/assembly/assembly.xml Zobrazit soubor

@@ -0,0 +1,30 @@
1
+<assembly>
2
+    <id>assembly</id>
3
+    <formats>
4
+        <format>tar.gz</format>
5
+    </formats>
6
+    <includeBaseDirectory>true</includeBaseDirectory>
7
+    <fileSets>
8
+        <fileSet>
9
+            <directory>src/main/assembly/bin</directory>
10
+            <outputDirectory>bin</outputDirectory>
11
+            <fileMode>0755</fileMode>
12
+        </fileSet>
13
+        <fileSet>
14
+            <directory>target/classes</directory>
15
+            <outputDirectory>conf</outputDirectory>
16
+            <includes>
17
+                <include>META-INF/**</include>
18
+                <include>*.yml</include>
19
+                <include>conf/**</include>
20
+            </includes>
21
+            <fileMode>0755</fileMode>
22
+        </fileSet>
23
+    </fileSets>
24
+    <dependencySets>
25
+        <dependencySet>
26
+            <useProjectArtifact>true</useProjectArtifact>
27
+            <outputDirectory>lib</outputDirectory>
28
+        </dependencySet>
29
+    </dependencySets>
30
+</assembly>

+ 86
- 0
CODE/smart-community/mq-message/src/main/assembly/bin/start.sh Zobrazit soubor

@@ -0,0 +1,86 @@
1
+#!/bin/bash
2
+
3
+SERVER_NAME='mq-meaasge'
4
+# jar名称
5
+JAR_NAME='mq-message-0.0.1.jar'
6
+cd `dirname $0`
7
+BIN_DIR=`pwd`
8
+cd ..
9
+DEPLOY_DIR=`pwd`
10
+CONF_DIR=$DEPLOY_DIR/conf
11
+# 获取应用的端口号
12
+SERVER_PORT=`sed -nr '/port: [0-9]+/ s/.*port: +([0-9]+).*/\1/p' conf/bootstrap.yml`
13
+
14
+PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
15
+if [ "$1" = "status" ]; then
16
+    if [ -n "$PIDS" ]; then
17
+        echo "The $SERVER_NAME is running...!"
18
+        echo "PID: $PIDS"
19
+        exit 0
20
+    else
21
+        echo "The $SERVER_NAME is stopped"
22
+        exit 0
23
+    fi
24
+fi
25
+
26
+if [ -n "$PIDS" ]; then
27
+    echo "ERROR: The $SERVER_NAME already started!"
28
+    echo "PID: $PIDS"
29
+    exit 1
30
+fi
31
+
32
+if [ -n "$SERVER_PORT" ]; then
33
+    SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
34
+    if [ $SERVER_PORT_COUNT -gt 0 ]; then
35
+        echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
36
+        exit 1
37
+    fi
38
+fi
39
+
40
+LOGS_DIR=$DEPLOY_DIR/logs
41
+if [ ! -d $LOGS_DIR ]; then
42
+    mkdir $LOGS_DIR
43
+fi
44
+STDOUT_FILE=$LOGS_DIR/stdout.log
45
+
46
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
47
+JAVA_DEBUG_OPTS=""
48
+if [ "$1" = "debug" ]; then
49
+    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
50
+fi
51
+
52
+JAVA_JMX_OPTS=""
53
+if [ "$1" = "jmx" ]; then
54
+    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
55
+fi
56
+
57
+JAVA_MEM_OPTS=""
58
+BITS=`java -version 2>&1 | grep -i 64-bit`
59
+if [ -n "$BITS" ]; then
60
+    JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
61
+else
62
+    JAVA_MEM_OPTS=" -server -Xms512m -Xmx512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
63
+fi
64
+
65
+CONFIG_FILES=" -Dspring.config.location=$CONF_DIR/ "
66
+echo -e "Starting the $SERVER_NAME ..."
67
+nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/lib/$JAR_NAME > $STDOUT_FILE 2>&1 &
68
+
69
+COUNT=0
70
+while [ $COUNT -lt 1 ]; do
71
+    echo -e ".\c"
72
+    sleep 1
73
+    if [ -n "$SERVER_PORT" ]; then
74
+        COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
75
+    else
76
+        COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
77
+    fi
78
+    if [ $COUNT -gt 0 ]; then
79
+        break
80
+    fi
81
+done
82
+
83
+echo "OK!"
84
+PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
85
+echo "PID: $PIDS"
86
+echo "STDOUT: $STDOUT_FILE"

+ 3
- 2
CODE/smart-community/mq-message/src/main/java/com/community/huiju/runner/MqRunner.java Zobrazit soubor

@@ -4,6 +4,7 @@ import com.community.huiju.common.hk.code.EventDis;
4 4
 import com.community.huiju.service.MqMessageServiceI;
5 5
 import org.apache.activemq.ActiveMQConnectionFactory;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.beans.factory.annotation.Value;
7 8
 import org.springframework.boot.ApplicationArguments;
8 9
 import org.springframework.boot.ApplicationRunner;
9 10
 import org.springframework.stereotype.Component;
@@ -23,8 +24,8 @@ import javax.jms.Topic;
23 24
 @Component
24 25
 public class MqRunner implements ApplicationRunner {
25 26
 	
26
-	//public static final String BROKER_URL = "failover:(tcp://192.168.0.122:61618)?timeout=2000";
27
-	public static final String BROKER_URL = "failover:(tcp://localhost:8877)?timeout=2000";
27
+	@Value("${broker.url}")
28
+	private String BROKER_URL;
28 29
 	
29 30
 	public static final String TARGET = "openapi.acs.topic";
30 31
 	

+ 1
- 2
CODE/smart-community/mq-message/src/main/resources/bootstrap.yml Zobrazit soubor

@@ -20,5 +20,4 @@ spring:
20 20
 eureka:
21 21
   client:
22 22
     service-url:
23
-      defaultZone: http://localhost:8080/eureka/
24
-
23
+      defaultZone: http://localhost:8080/eureka/

+ 19
- 0
CODE/smart-community/operate-api/pom.xml Zobrazit soubor

@@ -162,6 +162,25 @@
162 162
 				<groupId>org.springframework.boot</groupId>
163 163
 				<artifactId>spring-boot-maven-plugin</artifactId>
164 164
 			</plugin>
165
+			<!--服务化打包工具-->
166
+			<plugin>
167
+				<groupId>org.apache.maven.plugins</groupId>
168
+				<artifactId>maven-assembly-plugin</artifactId>
169
+				<configuration>
170
+					<descriptors>
171
+						<descriptor>src/main/assembly/assembly.xml</descriptor>
172
+					</descriptors>
173
+				</configuration>
174
+				<executions>
175
+					<execution>
176
+						<id>make-assembly</id>
177
+						<phase>package</phase>
178
+						<goals>
179
+							<goal>single</goal>
180
+						</goals>
181
+					</execution>
182
+				</executions>
183
+			</plugin>
165 184
 		</plugins>
166 185
 	</build>
167 186
 

+ 30
- 0
CODE/smart-community/operate-api/src/main/assembly/assembly.xml Zobrazit soubor

@@ -0,0 +1,30 @@
1
+<assembly>
2
+    <id>assembly</id>
3
+    <formats>
4
+        <format>tar.gz</format>
5
+    </formats>
6
+    <includeBaseDirectory>true</includeBaseDirectory>
7
+    <fileSets>
8
+        <fileSet>
9
+            <directory>src/main/assembly/bin</directory>
10
+            <outputDirectory>bin</outputDirectory>
11
+            <fileMode>0755</fileMode>
12
+        </fileSet>
13
+        <fileSet>
14
+            <directory>target/classes</directory>
15
+            <outputDirectory>conf</outputDirectory>
16
+            <includes>
17
+                <include>META-INF/**</include>
18
+                <include>*.yml</include>
19
+                <include>conf/**</include>
20
+            </includes>
21
+            <fileMode>0755</fileMode>
22
+        </fileSet>
23
+    </fileSets>
24
+    <dependencySets>
25
+        <dependencySet>
26
+            <useProjectArtifact>true</useProjectArtifact>
27
+            <outputDirectory>lib</outputDirectory>
28
+        </dependencySet>
29
+    </dependencySets>
30
+</assembly>

+ 86
- 0
CODE/smart-community/operate-api/src/main/assembly/bin/start.sh Zobrazit soubor

@@ -0,0 +1,86 @@
1
+#!/bin/bash
2
+
3
+SERVER_NAME='operate-api'
4
+# jar名称
5
+JAR_NAME='operate-api-0.0.1.jar'
6
+cd `dirname $0`
7
+BIN_DIR=`pwd`
8
+cd ..
9
+DEPLOY_DIR=`pwd`
10
+CONF_DIR=$DEPLOY_DIR/conf
11
+# 获取应用的端口号
12
+SERVER_PORT=`sed -nr '/port: [0-9]+/ s/.*port: +([0-9]+).*/\1/p' conf/bootstrap.yml`
13
+
14
+PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
15
+if [ "$1" = "status" ]; then
16
+    if [ -n "$PIDS" ]; then
17
+        echo "The $SERVER_NAME is running...!"
18
+        echo "PID: $PIDS"
19
+        exit 0
20
+    else
21
+        echo "The $SERVER_NAME is stopped"
22
+        exit 0
23
+    fi
24
+fi
25
+
26
+if [ -n "$PIDS" ]; then
27
+    echo "ERROR: The $SERVER_NAME already started!"
28
+    echo "PID: $PIDS"
29
+    exit 1
30
+fi
31
+
32
+if [ -n "$SERVER_PORT" ]; then
33
+    SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
34
+    if [ $SERVER_PORT_COUNT -gt 0 ]; then
35
+        echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
36
+        exit 1
37
+    fi
38
+fi
39
+
40
+LOGS_DIR=$DEPLOY_DIR/logs
41
+if [ ! -d $LOGS_DIR ]; then
42
+    mkdir $LOGS_DIR
43
+fi
44
+STDOUT_FILE=$LOGS_DIR/stdout.log
45
+
46
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
47
+JAVA_DEBUG_OPTS=""
48
+if [ "$1" = "debug" ]; then
49
+    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
50
+fi
51
+
52
+JAVA_JMX_OPTS=""
53
+if [ "$1" = "jmx" ]; then
54
+    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
55
+fi
56
+
57
+JAVA_MEM_OPTS=""
58
+BITS=`java -version 2>&1 | grep -i 64-bit`
59
+if [ -n "$BITS" ]; then
60
+    JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
61
+else
62
+    JAVA_MEM_OPTS=" -server -Xms512m -Xmx512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
63
+fi
64
+
65
+CONFIG_FILES=" -Dspring.config.location=$CONF_DIR/ "
66
+echo -e "Starting the $SERVER_NAME ..."
67
+nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/lib/$JAR_NAME > $STDOUT_FILE 2>&1 &
68
+
69
+COUNT=0
70
+while [ $COUNT -lt 1 ]; do
71
+    echo -e ".\c"
72
+    sleep 1
73
+    if [ -n "$SERVER_PORT" ]; then
74
+        COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
75
+    else
76
+        COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
77
+    fi
78
+    if [ $COUNT -gt 0 ]; then
79
+        break
80
+    fi
81
+done
82
+
83
+echo "OK!"
84
+PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
85
+echo "PID: $PIDS"
86
+echo "STDOUT: $STDOUT_FILE"

+ 19
- 0
CODE/smart-community/property-api/pom.xml Zobrazit soubor

@@ -106,6 +106,25 @@
106 106
 				<groupId>org.springframework.boot</groupId>
107 107
 				<artifactId>spring-boot-maven-plugin</artifactId>
108 108
 			</plugin>
109
+			<!--服务化打包工具-->
110
+			<plugin>
111
+				<groupId>org.apache.maven.plugins</groupId>
112
+				<artifactId>maven-assembly-plugin</artifactId>
113
+				<configuration>
114
+					<descriptors>
115
+						<descriptor>src/main/assembly/assembly.xml</descriptor>
116
+					</descriptors>
117
+				</configuration>
118
+				<executions>
119
+					<execution>
120
+						<id>make-assembly</id>
121
+						<phase>package</phase>
122
+						<goals>
123
+							<goal>single</goal>
124
+						</goals>
125
+					</execution>
126
+				</executions>
127
+			</plugin>
109 128
 		</plugins>
110 129
 	</build>
111 130
 

+ 30
- 0
CODE/smart-community/property-api/src/main/assembly/assembly.xml Zobrazit soubor

@@ -0,0 +1,30 @@
1
+<assembly>
2
+    <id>assembly</id>
3
+    <formats>
4
+        <format>tar.gz</format>
5
+    </formats>
6
+    <includeBaseDirectory>true</includeBaseDirectory>
7
+    <fileSets>
8
+        <fileSet>
9
+            <directory>src/main/assembly/bin</directory>
10
+            <outputDirectory>bin</outputDirectory>
11
+            <fileMode>0755</fileMode>
12
+        </fileSet>
13
+        <fileSet>
14
+            <directory>target/classes</directory>
15
+            <outputDirectory>conf</outputDirectory>
16
+            <includes>
17
+                <include>META-INF/**</include>
18
+                <include>*.yml</include>
19
+                <include>conf/**</include>
20
+            </includes>
21
+            <fileMode>0755</fileMode>
22
+        </fileSet>
23
+    </fileSets>
24
+    <dependencySets>
25
+        <dependencySet>
26
+            <useProjectArtifact>true</useProjectArtifact>
27
+            <outputDirectory>lib</outputDirectory>
28
+        </dependencySet>
29
+    </dependencySets>
30
+</assembly>

+ 86
- 0
CODE/smart-community/property-api/src/main/assembly/bin/start.sh Zobrazit soubor

@@ -0,0 +1,86 @@
1
+#!/bin/bash
2
+
3
+SERVER_NAME='property-api'
4
+# jar名称
5
+JAR_NAME='property-api-0.0.1.jar'
6
+cd `dirname $0`
7
+BIN_DIR=`pwd`
8
+cd ..
9
+DEPLOY_DIR=`pwd`
10
+CONF_DIR=$DEPLOY_DIR/conf
11
+# 获取应用的端口号
12
+SERVER_PORT=`sed -nr '/port: [0-9]+/ s/.*port: +([0-9]+).*/\1/p' conf/bootstrap.yml`
13
+
14
+PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
15
+if [ "$1" = "status" ]; then
16
+    if [ -n "$PIDS" ]; then
17
+        echo "The $SERVER_NAME is running...!"
18
+        echo "PID: $PIDS"
19
+        exit 0
20
+    else
21
+        echo "The $SERVER_NAME is stopped"
22
+        exit 0
23
+    fi
24
+fi
25
+
26
+if [ -n "$PIDS" ]; then
27
+    echo "ERROR: The $SERVER_NAME already started!"
28
+    echo "PID: $PIDS"
29
+    exit 1
30
+fi
31
+
32
+if [ -n "$SERVER_PORT" ]; then
33
+    SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
34
+    if [ $SERVER_PORT_COUNT -gt 0 ]; then
35
+        echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
36
+        exit 1
37
+    fi
38
+fi
39
+
40
+LOGS_DIR=$DEPLOY_DIR/logs
41
+if [ ! -d $LOGS_DIR ]; then
42
+    mkdir $LOGS_DIR
43
+fi
44
+STDOUT_FILE=$LOGS_DIR/stdout.log
45
+
46
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
47
+JAVA_DEBUG_OPTS=""
48
+if [ "$1" = "debug" ]; then
49
+    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
50
+fi
51
+
52
+JAVA_JMX_OPTS=""
53
+if [ "$1" = "jmx" ]; then
54
+    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
55
+fi
56
+
57
+JAVA_MEM_OPTS=""
58
+BITS=`java -version 2>&1 | grep -i 64-bit`
59
+if [ -n "$BITS" ]; then
60
+    JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
61
+else
62
+    JAVA_MEM_OPTS=" -server -Xms512m -Xmx512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
63
+fi
64
+
65
+CONFIG_FILES=" -Dspring.config.location=$CONF_DIR/ "
66
+echo -e "Starting the $SERVER_NAME ..."
67
+nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/lib/$JAR_NAME > $STDOUT_FILE 2>&1 &
68
+
69
+COUNT=0
70
+while [ $COUNT -lt 1 ]; do
71
+    echo -e ".\c"
72
+    sleep 1
73
+    if [ -n "$SERVER_PORT" ]; then
74
+        COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
75
+    else
76
+        COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
77
+    fi
78
+    if [ $COUNT -gt 0 ]; then
79
+        break
80
+    fi
81
+done
82
+
83
+echo "OK!"
84
+PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
85
+echo "PID: $PIDS"
86
+echo "STDOUT: $STDOUT_FILE"