Categories
Uncategorized

Running EventStore as a Windows Service

I’ve been experimenting with EventStore lately. So far it appears to be a great product. The documentation is both good and bad. There is very, very little documentation, yet everything seems to be there. You just need to know where to dig, or watch/read some of the internals videos/blog posts.

The product ships as a simple command line application. That’s great, because it gives you all the flexibility you want. But you probably want to run it in the background as a service anyway so let’s do that.

I set up my machine to support multiple versions without having to change my service definition with every product upgrade. So I created the following drive structure

C:
└─EventStore
  ├─4.0.3-hf1
  ├─data
  ├─latest (--> ./4.0.3-hf1)
  └─logs

where latest is an NTFS junction point to the directory containing the binaries for the latest version. When a new version is released, I can just change to junction point to the newest version.

Next step is to create a Windows Service but EventStore.ClusterNode.exe cannot run as a service directly so you need to wrap it inside a service wrapper like NSSM or winsw. I chose the latter simply because it looked to be the most foolproof to me. I downloaded the WinSW.NET4.exe binary from the releases tab, copied it to C:\EventStore and then renamed it to EventStore.ServiceWrapper.exe. To finish the configuration of the service wrapper, all I needed is an xml file with the service definition in it. Here’s mine.

<configuration>
  <id>EventStore</id>
  <name>EventStore</name>
  <description>EventStore</description>
  <executable>%BASE%\latest\EventStore.ClusterNode.exe</executable>
  <arguments>--db=%BASE%\data --log=%BASE%\logs --run-projections=all --start-standard-projections=true</arguments>
  <startmode>Manual</startmode>
</configuration>

Finally, we need to install/register the Windows Service by calling

C:\EventStore> EventStore.ServiceWrapper.exe install

in a shell with administrative privileges (Windows button + X > Command Prompt (Admin)). Using that shell, you can also start the service

C:\EventStore> net start EventStore

Easy, right?