r/java•
Killercds

Running apps as services: Is there a standard?

I was tired of trying to keep track of things in Windows service manager, and of people trying to start duplicate instances of services... so I whipped up a tiny service manager program: It works, but it's not pretty lol

The idea was to start desired programs as a child process, store PIDs, check for duplicate instances of services, and pass start/stop/status type messages using a buffer file

The Main Question:
Is there an actual standard, open-source way of managing and tracking java apps running as services? Or is rolling your own launcher/manager expected?

Edit: I am very aware of systemd/initd/systemctl; but I can't always win the "we should run this on linux" argument 🤷

Posted Mar 11, 2022, 4:35 PM UTC · edited

56
Worth_Trust_3825•

On linux you would use systemd/initd.

On windows things get a bit more complicated, because the executable must implement service interface. To solve that there's winsw, nssm, which permit running arbitrary applications as services.

As for your main question, as a devops, i'd rather see your application running as a service, rather than hacked together via some launcher scripts. That way I can just hook into service manager and see what's down when I get a message in the middle of the night that some page that's the first time I'm hearing about is down.

7
Sheldor5•

on Linux you have systemd/systemctl which does exactly what you are trying to do on Windows

3
mirkoteran•

We use https://github.com/winsw/winsw without any problems for years.

3
Persism•

For Windows I used JSL http://www.roeschter.de/ - works great!

1
NathanClayton•

I used to have that issue f how to start and manage services in Linux and Windows.

Now I build everything as a container image and run it in Docker, either as an auto-starting service on one specific server, or managed by an orchestrator, like Kubernetes. Another nice thing is that as long as you're running Linux containers on Windows, it's the same container running, regardless of the host system.

1
[deleted]•

[deleted]

0