@@ -25,13 +25,14 @@ if [ ! -d "$SYSTEMD_DIR" ]; then
2525 exit 1 # Exit with an error status
2626fi
2727
28- if [ -z " $JAVA_HOME " ] ; then
29- echo " JAVA_HOME is not set . Please set the JAVA_HOME environment variable ."
28+ if ! java --version > /dev/null 2>&1 ; then
29+ echo " java command is not available . Please install Java or ensure it is in PATH ."
3030 exit 1
3131fi
3232
3333FILE_NAME=$SYSTEMD_DIR /iotdb-confignode.service
3434
35+ if [ -z " $JAVA_HOME " ]; then
3536cat > " $FILE_NAME " << EOF
3637[Unit]
3738Description=iotdb-confignode
@@ -46,6 +47,34 @@ Type=simple
4647User=root
4748Group=root
4849Environment=JAVA_HOME=$JAVA_HOME
50+ Environment=PATH=$JAVA_HOME /bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
51+ ExecStart=$IOTDB_SBIN_HOME /start-confignode.sh
52+ ExecStop=$IOTDB_SBIN_HOME /stop-confignode.sh
53+ Restart=on-failure
54+ SuccessExitStatus=143
55+ RestartSec=5
56+ StartLimitInterval=600s
57+ StartLimitBurst=3
58+ RestartPreventExitStatus=SIGKILL
59+
60+ [Install]
61+ WantedBy=multi-user.target
62+ EOF
63+ else
64+ cat > " $FILE_NAME " << EOF
65+ [Unit]
66+ Description=iotdb-confignode
67+ Documentation=https://iotdb.apache.org/
68+ After=network.target
69+
70+ [Service]
71+ StandardOutput=null
72+ StandardError=null
73+ LimitNOFILE=65536
74+ Type=simple
75+ User=root
76+ Group=root
77+ Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4978ExecStart=$IOTDB_SBIN_HOME /start-confignode.sh
5079ExecStop=$IOTDB_SBIN_HOME /stop-confignode.sh
5180Restart=on-failure
@@ -58,6 +87,7 @@ RestartPreventExitStatus=SIGKILL
5887[Install]
5988WantedBy=multi-user.target
6089EOF
90+ fi
6191
6292echo " Daemon service of IoTDB ConfigNode has been successfully registered."
6393
0 commit comments