Linux下启动Java守护进程方法

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
#!/bin/sh
DESC="Java Service"
NAME=java-service
PIDFILE=/tmp/$NAME.pid
PATH_TO_JAR=~/java-service.jar
PATH_TO_JAVA=/usr/local/jdk1.8.0_131/bin/java
SERVICE_CONFIG='-Dserver.port=8080 -DLOG_PATH=/var/log'
COMMAND="$PATH_TO_JAVA -- $SERVICE_CONFIG -jar $PATH_TO_JAR"
d_start() {
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $COMMAND
}
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE
if [ -e $PIDFILE ]
then rm $PIDFILE
fi
}
case $1 in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit 0

Read More

HPKP(HTTP Public Key Pinning)详解

HPKP是什么

HPKP(HTTP Public Key Pinning)又名公钥打孔,可以通过告知客户端将特定的加密公钥与特定服务器关联,以减少通过伪造证书进行中间人攻击(MITM)的风险.

Read More

PostgreSQL JDBC time类型存取细节

  • PostgreSQL中默认时区为UTC
  • record表中有一类型为Time without timezone的字段event_time
  • 本机的时区为UTC+8

Read More

Hibernate学习

占位符(named parameters)对order by无效

1
2
//对于最后两字段sortField和sortOrder设值时是没有效果的
SELECT * FROM t_table WHERE column=:param1 ORDER BY :sortField :sortOrder

Read More

Groovy学习

sort方法作用于Set和List时的区别

1
2
3
4
5
6
7
8
def a = new HashSet()
a << [3, 1, 2]
def b = new ArrayList()
b << [2, 1, 3]
assert b.sort().is(b) //true
assert a.sort().is(a) //false

Read More

Tomcat传递环境变量

  • 在Tomcat bin目录下新建setenv.sh, 编辑setenv.sh,添加如下语句

    1
    export JAVA_OPTS="-DKEY1=VALUE1 -DKEY2=VALUE2 -DKEY3=VALUE3"

Read More