Keep GlassFish Windows Service running 24/7 with Service Protector

How to Keep the GlassFish Windows Service Running 24/7 with Service Protector

Automatically restart GlassFish when it crashes or stops for any reason. Periodically restart it at a safe time to cure memory leaks.

GlassFish is an open-source Java application server supported by Oracle. It can be configured to start as a Windows Service, to run unattended in the background in a 24x7 server environment:

To protect the GlassFish Windows Service with Service Protector:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, in the Service to protect field, choose your GlassFish windows service. Your service will probably be named something like domain1 GlassFish Server, the default when installing GlassFish as a windows service, but it could have been renamed to something else. It is called "GlassFish Server" on our Windows Server 2012 test machine and you will see that name throughout this tutorial.

    GlassFish Windows Service: General Tab

  5. If you find that GlassFish gets slower over time we recommend that you periodically restart the service at a time when no one is likely to be using the server. To do so, switch over to the Monitor tab and:

    1. Check the At the following times box.

    2. Click the Add button.

    3. Specify the day and time to restart the service. We have chosen every day at 3 AM. Note that you can choose to reboot the server at that time if you like.

    4. Click the OK button to record the time.

    GlassFish Windows Service: Monitor Tab

  6. Click the Save button. In a few seconds, an entry for GlassFish will show up in the Service Protector window. GlassFish is probably already running but it is not yet being protected by Service Protector (as shown below).

    GlassFish Windows Service: Created

  7. To start protection, choose Protector > Start "GlassFish Server" (or whatever you named your GlassFish service). In a couple of seconds the shield icon on the right will go to green to indicate that GlassFish is being monitored by Service Protector:

    GlassFish Windows Service: Protected

  8. That's it! Next time your computer boots, GlassFish will start automatically and Service Protector will start watching the service to quickly restart it if it stops for any reason.

    We encourage you to edit the GlassFish entry in Service Protector and check out the many other settings that may be beneficial to your environment. For example, send an email when the service fails, configure a sanity check to monitor the web interface and bounce the service when it fails, and much more.



Trouble protecting the GlassFish Windows Service?