Erlang, rebar3 and service installation under Windows
How to make Erlang release work as a service under Windows. We leave behind the scenes the question of why this is done. It’s just sometimes necessary. So let's focus on HOW. To make it even more difficult, we set ourselves the task of doing this using wixtoolset .
This note is a crib to myself. Although I really hope that it will never come in handy. Go.
Imagine that we somehow set the files and brought the run time with us. Application launch in the form of a console is triggered and now we need to arrange the application launch in the form of a service. If there is a problem already at this stage - write to me, I just stamped around there.
So, here we are waiting for some fun pitfalls. We can somehow run the NAME-APPLICATION script. Cmd install. And it will even work. But there are 2 drawbacks - the black screen jumps up and the service is not deleted when the application is deleted.
So let's move on to what will be lacking:
1) The erl.ini file in the erts-NUMBER \ bin directory. After installation, its contents contain the paths of the machine where the release was collected. Its contents must be changed. And you need to put double slashes in the paths.
2) The service is started using the erlsrv.exe file. This is part of the runtime, everything is fine here. We must not forget to take it with you.
3) erlsrv.exe expects to find the start.boot file at releases \ VERSION. But he is not there. And you need to copy it
4) erlsrv.exe stores the service parameters in a register. And they must be completed by ourselves.
Now examples
For example, our miracle application is called erlang_service. We write in the register:
Here we have this:
--rootdir - the place where the application is installed. Exactly. If we take for example [ROOT] - id of the directory itself, then nothing will work, since there will be a slash at the end. And it confuses him.
InternalServiceName Value = "erlang_service" - under this name we will put the service.
SName is erlang short name
[ROOT] - the ID of the directory in which our files are located.
Well, the service itself:
As a result, we have a service that is automatically installed, stopped and correctly deleted.
All.