Auto-Restart RavenDB when it fails

How to Automatically Restart the RavenDB Windows Service when it Stops

Monitor RavenDB and keep it running 24/7, even if it crashes or stops for any reason.

RavenDB is an advanced, transactional document database. It can be installed as a standalone Windows Service:

To monitor the RavenDB 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, choose RavenDB from the list of services in the Service to protect field. The green circle indicates that RavenDB is already running...

    RavenDB Windows Service: General Tab

  5. To monitor and automatically restart RavenDB if it stops responding to HTTP requests (or returns a dreaded 5XX/Internal Server error), go to the Monitor tab where we'll set up a failure detection script that Service Protector will use to tell when RavenDB has failed.

    1. Follow these instructions to create the failure detection BAT file. We have called ours check-ravendb.bat and saved it in the RavenDB installation folder, C:\RavenDB.

    2. Check the Whenever it fails a "sanity check" box and click the "..." button to open the Configure Sanity Check window. Enter the full path to the batch file you created, enclosing the whole value in quotes if it contains one or more spaces.

    3. Change the Every controls to 5 minutes, or however often you wish to check RavenDB's web interface.

    4. Press the OK button to save your sanity check settings.

    RavenDB Windows Service: Monitor Tab

  6. We're now done configuring the essentials for RavenDB so click the Save button to record your settings. A new entry called RavenDB will show up in the Service Protector window. RavenDB is probably already running but it is not yet being protected by Service Protector (hence the red shield). At this point, you can click on the green circle to see a few details on the RavenDB Windows Service and its underlying process:

    RavenDB Windows Service: Created

  7. To start protecting RavenDB, choose Protector > Start "RavenDB". The shield icon (which is clickable as well) will go to green to indicate that RavenDB is being actively monitored by Service Protector.

    RavenDB Windows Service: Running

  8. That's it! Next time your computer boots, RavenDB will start as normal and Service Protector will begin monitoring the service to quickly restart it if it fails or stops for any reason.

    We encourage you to edit RavenDB in Service Protector and check out the many other settings that may be appropriate for your situation. For example, send an email when the service fails, restart RavenDB during the early morning to diminish the effect of memory leaks, etc.

Trouble protecting the RavenDB Windows Service?