distillery icon indicating copy to clipboard operation
distillery copied to clipboard

Installed service won't automatically start in Windows 10

Open dabaer opened this issue 6 years ago • 2 comments

Steps to reproduce

  1. Compile the release as normal (MIX_ENV=prod mix release --env=prod)
  2. Navigate to the build bin directory (_build/prod/rel/project/bin)
  3. Install the service using project.bat install
  4. Start the service using project.bat start
  5. Reboot Windows

Verbose Logs

Windows Event viewer outputs the following error:

The project01d4b8d12dbe2a20 service terminated with the following error: The configuration registry key could not be read.

Description of issue

- What are the expected results?

  • For the release to start automatically after a reboot

- What version of Distillery?

  • Master, commit ae023530e55539870847ce13ab5e11d37ea8d4ca, though i can see this issue as far back as Jan 2018, first spotted at https://elixirforum.com/t/distillery-windows-10-hot-upgrade-questions/11313

- What OS, Erlang/Elixir versions are you seeing this issue on?

  • Windows 1809 build 17763.253
  • Erlang 21.2
  • Elixir 1.8

- If possible, also provide your rel/config.exs, as it is often my first troubleshooting question, and you'll save us both time :)

  • Unmodified from the generated file, aside from:
environment :prod do
  <...>
  set include_erts: true
  <...>
end

- Is there documentation that says one thing, but Distillery does another? If so, please link the doc here so it can be updated if it's a documentation issue, or so that the fix can be based around what's documented.

  • I can't seem to find anything about running it as a service on Windows. I only found out it was even an option by fluke, running the project command with an invalid argument.

- If this is a runtime configuration issue, please also provide your config file (with any sensitive information stripped of course). This is almost always necessary to understand why some configuration may not be working.

  • N/A

I will fiddle with the service, I see an option to restart the service if it failed to start in the first place which might work if setting the service mode to Automatic (Delayed) start fine for the person in the article I posted above. Ideally I need it to start almost immediately, but I can probably survive with a delayed start.

To note, the service started fine if started manually, and on delayed start, but not on the Automatic setting.

dabaer avatar Jan 30 '19 19:01 dabaer

I think the problem is related to this: https://groups.google.com/forum/#!topic/erlang-programming/kATOOaYBflA

PaoloLaurenti avatar Jun 04 '19 10:06 PaoloLaurenti

The only "solution" I found is to set the Startup Type of the Windows Service to Automatic (Delayed Start).
I can provide a PR where the install.ps1 can set the Windows Service created by erlsrv with this configuration. @bitwalker could this be OK for you?

PaoloLaurenti avatar Jun 05 '19 10:06 PaoloLaurenti