Create a windows service for nginx.exe using install4J

64 Views Asked by At

Using install4j I want to create a windows service that runs nginx.exe.

I tried to create a service using the option of Other service executable, it manages to install it but when started it throws an error: Error 1053: The service didn't respond to the start or control request in a timely fashion

I understand that I would need a special .exe file that is accepted by windows to be wrapped as a service.

Can this be done in anyway using install4j and without any 3rd party tool?

2

There are 2 best solutions below

3
Ingo Kegel On

In the "Install a service" action in install4j, you have to specify a generated service launcher or an external Windows service executable. nginix.exe is not a Windows service executable, but a console executable.

0
George Catalin On

The solution I chose was to use a third party tool called WinSW. You can find it here Windows Service Wrapper You can find instructions there about how it should be used.

I created a .bat script that I call from the install4j and in the script I use the commands needed for calling winsw.

It's not great, but it seems to work. Unfortunately I had to create a script that I use while installing the service and a second script that I use for stopping the service in the uninstall process.