Skip to content

Instantly share code, notes, and snippets.

@valery1707
Created December 15, 2015 09:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valery1707/c4ca44744496eeac5c79 to your computer and use it in GitHub Desktop.
Save valery1707/c4ca44744496eeac5c79 to your computer and use it in GitHub Desktop.
JBoss (WildFly) configuration for Systemd for Ubuntu 15.10
#edit => sudo systemctl edit --system --full va-wildfly
#refresh system status => sudo systemctl daemon-reload
#status=> sudo systemctl status va-wildfly
#start => sudo systemctl start va-wildfly
#stop => sudo systemctl stop va-wildfly
[Unit]
Description=WildFly application server
After=syslog.target
After=network.target
[Service]
Environment="USER=wildfly"
Environment="HOME=/srv/wildfly/wildfly-9.0.2.Final"
Environment="CONF=standalone"
Environment="JBOSS_PIDFILE=/var/run/wildfly.pid"
Environment="LOG_DIR=standalone/log"
Environment="LOG_CONSOLE=console.log"
Environment="CONFIG=standalone.xml"
Environment="SCRIPT=standalone.sh"
ExecStartPre=/bin/echo '[INFO] Prepare environment'
ExecStartPre=/bin/mkdir --verbose --parents ${HOME}/${LOG_DIR}
ExecStartPre=/usr/bin/touch ${HOME}/${LOG_DIR}/${LOG_CONSOLE}
ExecStartPre=-/bin/chown --verbose --recursive $USER ${HOME}/${LOG_DIR}
ExecStartPre=/usr/bin/truncate --size=0 ${HOME}/${LOG_DIR}/${LOG_CONSOLE}
ExecStartPre=-/bin/rm --force ${HOME}/standalone/deployments/*.failed
ExecStartPre=-/bin/rm --force --recursive ${HOME}/standalone/tmp/vfs/*
ExecStartPre=/bin/bash -c '/bin/echo "[INFO] Run WildFly at $(/bin/date --rfc-3339=seconds)"'
Type=forking
ExecStart=/sbin/start-stop-daemon --start --background --chuid ${USER} --chdir ${HOME} --pidfile ${JBOSS_PIDFILE} --exec /bin/bash -- -c "${HOME}/bin/${SCRIPT} -c ${CONFIG} | /usr/bin/tee ${HOME}/${LOG_DIR}/${LOG_CONSOLE}"
TimeoutStartSec=0
ExecStartPost=/bin/echo '[INFO] Wait for tag-lines in log file'
# WFLYSRV0010: Deployed "*.war" (runtime-name : "*.war")
ExecStartPost=/bin/bash -c 'while ! /bin/grep "WFLYSRV0010" "${HOME}/${LOG_DIR}/${LOG_CONSOLE}" -q ; do /bin/sleep 2s ; done'
# WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 110186ms
ExecStartPost=/bin/grep "WFLYSRV0025" "${HOME}/${LOG_DIR}/${LOG_CONSOLE}"
ExecStartPost=/bin/bash -c 'echo "[INFO] WildFly started at $(/bin/date --rfc-3339=seconds)"'
ExecStop=/bin/kill -TERM $MAINPID
TimeoutStopSec=20s
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment