Setting up a Linux service to run your Wildfly Web Server will allow the server to continuously run in the background, without any user interaction. Another advantage of a Linux service is that it will run no matter which user is logged onto the machine. This means you do not have to leave a user logged onto the server just to keep Wildfly running. You can also configure the service to start automatically if the system is rebooted.
The information in this section will guide you through setting up Wildfly 17 to run as a Linux Service.
Overview of Steps
These are the basic steps that will be taken to set up the Linux Service.
Overview of Directories Involved in the Process
The following is an overview of the directories that will be used and referenced during the process of setting up JBoss to run as a service.
Directory | Description |
---|---|
/etc | Standard Linux directory that contains the configuration files for the system. |
/etc/init.d | Standard Linux directory that contains the startup scripts for various system services. |
/wildfly-17.0.0.Final/bin/init.d | Wildfly directory that was created when Wildfly was installed. |
The remaining sections will outline the steps to setup Wildfly to run as a Linux service.
Step 1: Change Working Directory
The first step is to log into the terminal and change your working directory to the init.d directory in your Wildfly directory. The init.d directory in your Wildfly directory contains the configuration file and script to start Wildfly.
Steps to Change Working Directory
Step 2: Copy the Wildfly Init Directory
The second step in this process is to copy the Wildfly Control Script called wildfly-init-redhat.sh to the initialization directory on your Linux server. The wildfly-init-redhat.sh file contains the start and stop commands for the Wildfly Server and by copying it to your initialization directory the Wildfly server will be able to start automatically when the system is rebooted.
Steps to Copy jboss-as-standalone.sh File
Assumptions: you are still logged into the terminal and the working directory is /jboss-as-7.1.1.1.Final/bin/init.d
Step 3: Create a New Directory
The third step in this process is to create a new directory in the standard etc directory. This new directory will contain the configuration file for when the JBoss service is started.
Create Directory Steps
Step 4: Copy Configuration File to New Directory
The fourth step is to copy the configuration file called wildfly.conf to the directory you just created in the previous step. This file contains the general configuration for the init.d scripts.
Steps to Copy wildflyconf File
Assumptions: you are still logged into the terminal and the working directory is /wildfly-10.0.0.Final/docs/contrib/scripts/init.d
Step 5: Edit Configuration File
The fifth step is to edit the JBOSS_USER in the jwildfly.conf file that you just copied to the wildfly directory in your etc directory. The JBoss user is the person who owns the process of stopping and starting the Wildfly server.
Steps to Update JBOSS_USER
Important
If you are connected to the server remotely then you will need to alter the above command to open it with a text editor. Instead of open you would type vi or whatever editor command is appropriate for your environment.
Example: vi /etc/defaults/wildfly.conf
Step 6: Start Wildfly and Verification
The sixth and final step is to start Wildfly and verify it is running correctly.