Ensuring that your WildFly server is up and running is essential for maintaining the health and availability of your applications. This article will guide you through various methods to check if your WildFly server is running.
Starting the server and checking the status
When you start the application server, a set of System Properties are attached to the Java process. This makes easy to detect which Java processes are related to the application server:
Therefore, a simple and effective strategy is to check the list of processes and grep for ‘jboss’:
ps -ef | grep jboss | grep -v grep
You can also check the server status through the HTTP public address and port with any tool like curl:
curl -s http://localhost:8080 | grep WildFly <title>Welcome to WildFly</title> <img src="wildfly_logo.png" alt="WildFly" border="0" /> <h1>Welcome to WildFly</h1> <h3>Your WildFly instance is running.</h3> <p><a href="https://wildfly.org">WildFly Project</a> |
In some environment, for example Cloud environment, you might have only a limited set of commands. However, the jps command line is available upon JDK installation. Therefore, you can use the jps command to check the server status.
In the following example, we are storing the PID of a JBoss/WildFly server in the PID environment variable:
PID=$(jps -lv | grep -i jboss | cut -d ' ' -f 1)
If you need a file system method to check the server status, then you can check within the $JBOSS_HOME/standalone/tmp folder. When the server is running, you will find the startup-marker file in there:
ls -al /home/jboss/wildfly-26.0.1.Final/standalone/tmp total 4 drwxr-xr-x. 1 francesco francesco 106 Feb 22 15:44 . drwxr-xr-x. 1 francesco francesco 74 Feb 1 16:00 .. -rw-rw-r--. 1 francesco francesco 21 Feb 22 15:44 startup-marker drwxrwxr-x. 1 francesco francesco 28 Feb 22 15:44 vfs
When the server stops, the startup-marker file will be removed.
How to check WildFly status from the CLI
You can check JBoss / WildFly status from the CLI in different ways. If you are running in standalone mode, then you can just execute an “ls” command from the server root:
You can also fetch the server state in a no-interactive way. For example:
/jboss-cli.sh -c --commands=":read-attribute(name=server-state)"
Then, if you are running WildFly in Domain Mode, you need to reference your Host Controller to read the status
attribute. For example:
/host=slave-1/server-config=REST-server-one:read-attribute(name=status)
Finally, if you go do a grep
on the Server logs, you can check both the server status and the list of applications deployed:
cat ../standalone/log/server.log | grep WFLYSRV . . . . 022-02-22 16:04:09,053 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 26.0.1.Final (WildFly Core 18.0.4.Final) started in 4592ms - Started 615 of 764 services (353 services are lazy, passive or on-demand) 2022-02-22 16:04:09,054 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management 2022-02-22 16:04:09,054 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
Conclusion
Monitoring your WildFly application server is crucial for ensuring the smooth operation of your applications. By using the methods outlined in this article, you can easily verify if your WildFly server is running. Whether you prefer using log files, command-line tools, the Management Console, or automated scripts, these techniques will help you keep your server in check and maintain its reliability.
To learn more on how to check the application status, check this article: How to check if an application is running on WildFly