Running Cockroach as a Service on Windows?


I’m currently trying to get Cockroach running on my Windows machine as a service, but to no avail. I’ll admit that I’m not well-versed with creating/running Windows services, but I’ve had some success with other golang apps that I’ve compiled (after some messing around to ensure that the output .exe was service-compatible).

Are there any resources/guides/FAQs related to this topic, that might assist me? I’m not having too much luck with my Google-Fu.

Thanks! :slight_smile:

What have you tried, what did you observe, and what did not work?

I’ve tried creating the service, configured to execute ‘cockroach.exe’ (incl. path to executable), and several program arguments (‘start --insecure etc’). As far as creating services go, I’m really not sure what else I can try (even though what I’ve done isn’t much). By all measures, it looks like it’s correctly configured. If I open up the properties page for the service I create, it is correctly receiving the program & program arguments that I specified (so much so that if I copy/paste it in to my Command Prompt, it succeeds).

My (loose) understanding is that executables need to be compiled in a way that is “Windows Service Compatible”? I’ve weighed up options such as wrapping the service with nssm, but I’d really like to avoid additional files/executables where possible.

@Bram do you want to have a look?

@JJMurt, can you clarify what the actual problem is? It sounds like you’ve created the service, configured it, and are able to confirm that the configuration is correct. Is the service not able to run? Are you getting an error somewhere along the way?

Hey @JJMurt,

So at this point, we just don’t have any immediate plans to support running cockroach on Windows for anything other than just development purposes. So while we do provide an executable, it is not as thoroughly tested as our linux ones are and we suggest running it in production on a linux machine.

To provide CockroachDB as a Windows service, we would have to add a good amount of Windows service specialized code, an installer, and spend a lot more time testing it in Windows. All of these things are achievable, and we will provide them at some point, but not in the near future unless there is a fairly large response from the community for this.

So for this, I created a new issue to track it:

All that being said, NSSM looks like a great way to wrap the executable and might just work. And we’ll gladly help you out as best we can.

If you do get it working, please post the steps here! (or in the linked issue)

Thanks for the detailed response!
Sorry that I’ve not been able to eloquently express what the issues I’m facing are; but it feels like you’ve hit the nail on the head.

I’ll let you know if I have any luck with this endeavor. Cheers :slight_smile: