Hallo,
ich habe hier das Problem, dass ich fuer den Wildfy OS Jboss einen Check in den Startprozess einbauen will.
Wildfly Start und Stop funktioniert sauber. Da SystemD den Start abgeschlossen hat, sobald der Prozess gespawnt ist, also nicht erst wenn der Wildfly komplett oben ist und zum Beispiel den Webservice anbietet.
Hier will ich einen simplen curl check nach HTTP 200machen.
Hier kommt dann mein problem ins Spiel
SystemD Unit File
Code:
[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service
[Service]
Type=simple
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=202642
PIDFile=/var/run/wildfly/wildfly.pid
RemainAfterExit=true
ExecStart=/opt/wildfly/current/bin/standalone.sh -c $WILDFLY_CONFIG -P /opt/wildfly/current/wildfly.properties
ExecStartPost=/etc/wildfly/wildfly_start.sh <-- PROBLEM
ExecStop=/etc/wildfly/wildfly_shutdown.sh
[Install]
WantedBy=multi-user.target
Zu startende Standalone.sh
Code:
.
.
.
while true; do
# Execute the JVM in the background
eval \"$JAVA\" -D\"[Standalone]\" $JAVA_OPTS \
\"-Dorg.jboss.boot.log.file="$JBOSS_LOG_DIR"/server.log\" \
\"-Dlogging.configuration=file:"$JBOSS_CONFIG_DIR"/logging.properties\" \
-jar \""$JBOSS_HOME"/jboss-modules.jar\" \
$MODULE_OPTS \
-mp \""${JBOSS_MODULEPATH}"\" \
org.jboss.as.standalone \
-Djboss.home.dir=\""$JBOSS_HOME"\" \
-Djboss.server.base.dir=\""$JBOSS_BASE_DIR"\" \
"$SERVER_OPTS" "&"
JBOSS_PID=$!
HTTP 200 Check - wildfly_start.sh
Code:
#!/usr/bin/bash
sleep 5
## check is jolokia is up and running
http_return=400
while [ $http_return -ne 200 ]; do
http_return=$(curl -k -o /dev/null --silent --head --write-out '%{http_code}\n' https://localhost:8443/jolokia)
sleep 2
done
sleep 10
Sobald der Java Prozess gestartet wurde mit eval wird er auch wie gewuenscht in den Background verschoben. Damit ist SystemD fertig,
ich benoetige jedoch eine Funktion um den Abschluss des SystemD Startvorgangs auf den erfolgreichen Abschluss des HTTP 200 Checks zu verschieben.
Ich verstehe aktuell nicht wie ich das hinbekommen soll und die Doku hilft hier auch wenig.
Gruss Stefan
Lesezeichen