-
Notifications
You must be signed in to change notification settings - Fork 25
/
flipcast-start
executable file
·72 lines (53 loc) · 2.12 KB
/
flipcast-start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/bash
# Start script for flipcast service
#Application Name
PACKAGE=flipcast-service
#Application Jar
APP_JAR="flipcast-service.jar"
#OOM Restart Command
export OOM_RESTART_CMD="\"/etc/init.d/${PACKAGE} force-restart\""
#Memory settings
JAVA_OPTS="${JAVA_OPTS} -Xms512m"
JAVA_OPTS="${JAVA_OPTS} -Xmx512m"
JAVA_OPTS="${JAVA_OPTS} -XX:NewSize=256m"
JAVA_OPTS="${JAVA_OPTS} -XX:MaxNewSize=256m"
# Set Server JVM
JAVA_OPTS="${JAVA_OPTS} -server"
#Enable NUMA (For modern processors) - Reduces thread contention
JAVA_OPTS="${JAVA_OPTS} -XX:+UseNUMA"
# Set to headless, just in case
JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
#Set encoding to UTF-8
JAVA_OPTS="${JAVA_OPTS} -Dfile.encoding=UTF-8"
# Reduce the per-thread stack size
JAVA_OPTS="${JAVA_OPTS} -Xss180k"
# Force the JVM to use IPv4 stack
JAVA_OPTS="${JAVA_OPTS} -Djava.net.preferIPv4Stack=true"
# GC Options
JAVA_OPTS="${JAVA_OPTS} -XX:+UseCompressedOops"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseG1GC"
JAVA_OPTS="${JAVA_OPTS} -XX:+DisableExplicitGC"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseTLAB"
#Memory Setting
JAVA_OPTS="${JAVA_OPTS} -XX:MetaspaceSize=512m"
JAVA_OPTS="${JAVA_OPTS} -XX:MaxMetaspaceSize=512m"
#Enable super options (For HotSpot optimizations)
JAVA_OPTS="${JAVA_OPTS} -XX:+AggressiveOpts"
# General Tuning Settings
JAVA_OPTS="${JAVA_OPTS} -XX:CompileThreshold=50000"
# Causes the JVM to dump its heap on OutOfMemory.
JAVA_OPTS="${JAVA_OPTS} -XX:+HeapDumpOnOutOfMemoryError"
JAVA_OPTS="${JAVA_OPTS} -XX:OnOutOfMemoryError=${OOM_RESTART_CMD}"
#Setup remote JMX monitoring
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.port=29005"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
#Provide application configuration & log configuration file path
JAVA_OPTS="${JAVA_OPTS} -Dapp.config=config/application.conf"
JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=config/logback.xml"
#Java Executable
JAVA=`which java`
#Execute main application JAR
EXEC_CMD="exec -a ${PACKAGE} ${JAVA} -jar ${JAVA_OPTS} ${APP_JAR}"
eval ${EXEC_CMD}