I've got a little api web server (iz_client) that I need to deploy to windows server 2012 and am having a bit of trouble figuring out why it's failing to run as a service. The app is a bare bones phoenix app with HTTPoison being the only other dependency (exrm 1.0.6). I was able to successfully build a release and can run it from inside the phoenix directory with:
.\rel\iz_client\bin\iz_client console
In addition, I can install the service just fine with:
.\rel\iz_client\bin\iz_client install
However, I initially was unable to get the following command to work after the install:
.\rel\iz_client\bin\iz_client start
The windows event logs were saying that the process had unexpectedly quit and the reason was that not enough parameters had been passed to ErlSrv. I then dug around in the generated release code and made the following change on line 208 of iz_client.bat to get the start command working:
:: Start the Windows service
:start
@call :generate_config
@%erlsrv% start \"%service_name%\" <- This is my change, I had to escape the quotes
@goto :eof
Once the start command started working in powershell I opened up the services manager to configure the installed service and starting the service resulted in the same error as when I initially tried the powershell start command (not enough parameters passed to ErlSrv). This led me to believe that the service had been installed incorrectly. I then started looking at the install command and discovered that none of the variables were being set so that ErlSrv was adding a service with no arguments (resulting in the not enough parameters error). Here is the code from line 181-193 in the iz_client.bat file. I tried to echo a variable to confirm my suspicions and discovered that nothing is output for the %description% variable.
:install
@if "" == "%2" (
:: Install the service
set args=%erl_opts% %conform_opts% -setcookie %cookie% ++ -rootdir \"%rootdir%\"
set svc_machine=%erts_dir%\bin\start_erl.exe
set description=Erlang node %node_name% in %rootdir%
echo %description% test
%erlsrv% add %service_name% %node_type% "%node_name%" -c "%description%" ^
-w "%rootdir%" -m "%svc_machine%" -args "%args%" ^
-stopaction "init:stop()."
) else (
This is my first time dealing with a batch file so I'm not sure why these variables are not being set. If this is a known issue and there is an easy solution (seems like this may be the case) I'd really appreciate any help you can offer. Please let me know if you need more info.
I've got a little api web server (iz_client) that I need to deploy to windows server 2012 and am having a bit of trouble figuring out why it's failing to run as a service. The app is a bare bones phoenix app with HTTPoison being the only other dependency (exrm 1.0.6). I was able to successfully build a release and can run it from inside the phoenix directory with:
In addition, I can install the service just fine with:
However, I initially was unable to get the following command to work after the install:
The windows event logs were saying that the process had unexpectedly quit and the reason was that not enough parameters had been passed to ErlSrv. I then dug around in the generated release code and made the following change on line 208 of iz_client.bat to get the start command working:
Once the start command started working in powershell I opened up the services manager to configure the installed service and starting the service resulted in the same error as when I initially tried the powershell start command (not enough parameters passed to ErlSrv). This led me to believe that the service had been installed incorrectly. I then started looking at the install command and discovered that none of the variables were being set so that ErlSrv was adding a service with no arguments (resulting in the not enough parameters error). Here is the code from line 181-193 in the iz_client.bat file. I tried to echo a variable to confirm my suspicions and discovered that nothing is output for the %description% variable.
This is my first time dealing with a batch file so I'm not sure why these variables are not being set. If this is a known issue and there is an easy solution (seems like this may be the case) I'd really appreciate any help you can offer. Please let me know if you need more info.