distillery icon indicating copy to clipboard operation
distillery copied to clipboard

Starting in foreground mode on windows fails to get PID and returns errorlevel 1

Open mtsznowak opened this issue 7 years ago • 23 comments

Steps to reproduce

  • Install Windows 7 SP1
  • Create release with MIX_ENV=prod
  • Try to call _build\ENV\rel\YOURAPPNAME\VERSION\YOURAPPNAME.bat foreground

Verbose Logs

Paste the output of the release command you ran with the --verbose flag.

This is in Polish, but when you run it, it first fails with

"System nie może odnaleźć pliku %get_pid_cmd%.'

which means

"System is unable to locate file %get_pid_cmd%"

and than the subsequent call to tasklist fails with

"BŁĄD: Nieznany filtr wyszukiwania."

which means

"ERROR: Invalid search filter"

which makes sense as there's no PID after eq.

The app is being started despite the error.

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>vendor-app.bat foreground

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set rel_name=vendor-app

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set rel_vsn=0.8.0

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erts_vsn=8.3

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erl_opts=-smp enabled

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set script_dir=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for %A in ("C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\\..\..") do @(set release_root_dir=%~fA )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set rel_dir=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "" == "" (set mutable_dir=C:\app\src\backend\_build\prod\rel\vendor-app\var )  else (set mutable_dir=RELEASE_MUTABLE_DIR )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "" == "" (set config_dir=C:\app\src\backend\_build\prod\rel\vendor-app )  else (set config_dir= )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set log_dir=C:\app\src\backend\_build\prod\rel\vendor-app\var\log

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if not exist C:\app\src\backend\_build\prod\rel\vendor-app\var mkdir C:\app\src\backend\_build\prod\rel\vendor-app\var

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if not exist C:\app\src\backend\_build\prod\rel\vendor-app mkdir C:\app\src\backend\_build\prod\rel\vendor-app

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if not exist C:\app\src\backend\_build\prod\rel\vendor-app\var\log mkdir C:\app\src\backend\_build\prod\rel\vendor-app\var\log

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :find_erts_dir

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "8.3" == "" (call :use_system_erts )  else (call :use_bundled_erts )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erts_dir=C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erl=C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set rootdir=C:\app\src\backend\_build\prod\rel\vendor-app

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :find_sys_config

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set possible_sys=\sys.config

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if exist \sys.config (set sys_config_src=\sys.config )  else (set sys_config_src=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\sys.config )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set sys_config_target=C:\app\src\backend\_build\prod\rel\vendor-app\sys.config

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>powershell -command "$content = get-content C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\sys.config; [regex]::matches($content, '\${[\w\d_-]+}') | foreach { $content = $content.Replace($_.value, [System.Environment]::GetEnvironmentVariable($_.value)) }; out-file -filepath C:\app\src\backend\_build\prod\rel\radiokit-app\sys.config -inputobject $content -encoding ascii"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set sys_config=C:\app\src\backend\_build\prod\rel\vendor-app\sys.config

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :find_vm_args

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set possible_vmargs=\vm.args

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if exist \vm.args (set vmargs_src=\vm.args )  else (set vmargs_src=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\vm.args )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set vmargs_target=C:\app\src\backend\_build\prod\rel\vendor-app\vm.args

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>powershell -command "$content = get-content C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\vm.args; [regex]::matc
hes($content, '\${[\w\d_-]+}') | foreach { $content = $content.Replace($_.value, [System.Environment]::GetEnvironmentVariable($_.value)) }; out-file -filepath C:\app\src\backend\_build\prod\rel\radiokit-app\vm.args -inputobject $content -encoding ascii"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set vm_args=C:\app\src\backend\_build\prod\rel\vendor-app\vm.args

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :set_boot_script_var
System nie może znaleźć etykiety pliku wsadowego - set_boot_script_var

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set service_name=vendor-app_0.8.0

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set bindir=C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set progname=erl.exe

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set clean_boot_script=C:\app\src\backend\_build\prod\rel\vendor-app\bin\start_clean

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erlsrv="C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erlsrv.exe"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set epmd="C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\epmd.exe"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set escript="C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\escript.exe"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set werl="C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\werl.exe"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set nodetool="C:\app\src\backend\_build\prod\rel\vendor-app\bin\nodetool"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set consolidated_dir=C:\app\src\backend\_build\prod\rel\vendor-app\lib\vendor-app-0.8.0\consolidated

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set hook_dir=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set command_dir=C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\commands

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /F "usebackq tokens=1-2" %I in (`findstr /b "\-name \-sname" "C:\app\src\backend\_build\prod\rel\vendor-app\vm.args"`) do @
(
set node_type=%I
 set node_name=%J
)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /F "usebackq tokens=1-2" %I in (`findstr /b \-setcookie "C:\app\src\backend\_build\prod\rel\vendor-app\vm.args"`) do @(set cookie=%J )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :write_ini

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set erl_ini=C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl.ini

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set converted_bindir=C:\\app\\src\\backend\\_build\\prod\\rel\\vendor-app\\erts-8.3\\bin

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set converted_rootdir=C:\\app\\src\\backend\\_build\\prod\\rel\\vendor-app

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>echo [erlang]  1>"C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl.ini"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>echo Bindir=C:\\app\\src\\backend\\_build\\prod\\rel\\vendor-app\\erts-8.3\\bin  1>>"C:\app\src\backend\_build\prod\rel\radiokit-app\erts-8.3\bin\erl.ini"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>echo Progname=erl.exe  1>>"C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl.ini"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>echo Rootdir=C:\\app\\src\\backend\\_build\\prod\\rel\\vendor-app  1>>"C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl.ini"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if not exist "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\start.boot" (copy "C:\app\src\backend\_build\prod\
rel\vendor-app\releases\0.8.0\vendor-app.boot" "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\start.boot"  1>nul )

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set taskname="foreground"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>shift /1

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set args=

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>setlocal EnableDelayedExpansion

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set param=

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "!param!" == ""

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>endlocal   &

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "foreground" == "install"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "foreground" == "uninstall"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "foreground" == "start"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if "foreground" == "foreground"

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :pre_configure_hooks

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :execute_hooks pre_configure

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /R "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks\pre_configure.d" %f in (*.bat) do (

 %f

)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :post_configure_hooks

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :execute_hooks post_configure

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /R "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks\post_configure.d" %f in (*.bat) do (

 %f

)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :pre_start_hooks

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :execute_hooks pre_start

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /R "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks\pre_start.d" %f in (*.bat) do (

 %f

)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set EMU=beam

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set PROGNAME=vendor-app

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>start "" /B "C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\erl" -noshell -noinput +Bd        -boot "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\vendor-app"        -boot_var ERTS_LIB_DIR "C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\..\lib"        -env ERL_LIBS "C:\app\src\backend\_build\prod\rel\vendor-app\lib"        -pa "C:\app\src\backend\_build\prod\rel\vendor-app\lib\vendor-app-0.8.0\consolidated"        -args_file "C:\app\src\backend\_build\prod\rel\vendor-app\vm.args"        -config "C:\app\src\backend\_build\prod\rel\vendor-app\sys.config"        -smp enabled        -extra

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :set_pid

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :ping 1>NUL

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if 0 GEQ 1 exit 0

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>setlocal EnableDelayedExpansion

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>set get_pid_cmd="C:\app\src\backend\_build\prod\rel\vendor-app\erts-8.3\bin\escript.exe" "C:\app\src\backend\_build\prod\rel\vendor-app\bin\nodetool" eval -name [email protected] -setcookie "!cookie!" "erlang:list_to_integer(os:getpid()).'

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /F "delims=" %i in (`%get_pid_cmd%`) do set pid=%i
System nie może odnaleźć pliku `%get_pid_cmd%`.

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>endlocal

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :post_start_hooks

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :execute_hooks post_start

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /R "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks\post_start.d" %f in (*.bat) do (

 %f

)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>tasklist /FI "PID eq "   | find /I "erl.exe"
BŁĄD: Nieznany filtr wyszukiwania.

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>if 1 GEQ 1 (call :post_stop_hooks )  else (


)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>call :execute_hooks post_stop

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>for /R "C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0\hooks\post_stop.d" %f in (*.bat) do (

 %f

)

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>goto :eof

C:\app\src\backend\_build\prod\rel\vendor-app\releases\0.8.0>echo %ERRORLEVEL%
1

Description of issue

  • What are the expected results?

The app starts and script returns no error and errorlevel 0.

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

Windows 7 SP1 32-bit Elixir 1.4.4, Erlang 19.

  • If possible, also provide your rel/config.exs, as it is often my first troubleshooting question, and you'll save us both time :)
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
    # This sets the default release built by `mix release`
    default_release: :default,
    # This sets the default environment used by `mix release`
    default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
  set dev_mode: true
  set include_erts: false
  set cookie: :"XXXX"
end

environment :prod do
  case :os.type do
    {:unix, :linux} ->
      # Workaround for distillery_packager's problem with detecting arhitecture.
      # It uses uname, which returns machine hardware name, but not architecture 
      {arch, _ret} = System.cmd("dpkg", ["--print-architecture"]) 
      arch = arch |> String.replace("\n", "")

      plugin DistilleryPackager.Plugin, %{architecture: arch}
    _ ->
      nil
  end
  set include_erts: true
  set include_src: false
  set cookie: :"XXXX"
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :'vendor-app' do
  set version: current_version(:vendor_app)
  set applications: [
    :vendor_app,
    :runtime_tools
  ]
end

mtsznowak avatar Oct 17 '17 13:10 mtsznowak

I have found out that the command for retreiving PIDs fails with Connection attempt from disallowed node error.

It seems it tries to pass the hardcoded cookie by adding -setcookie "!cookie!" to the command line options while my app uses a different cookie. When I substituted it manually with my real cookie, the it found the PID properly.

The delayed expansions seem not to work properly.

mspanc avatar Oct 17 '17 14:10 mspanc

I unfortunately won't have access to a Windows machine for a few weeks, but if anyone is interested in taking a look in the meantime, please do!

bitwalker avatar Oct 18 '17 18:10 bitwalker

@bitwalker It seems that

  1. replacing single quote with double quote in
set get_pid_cmd=%escript% %nodetool% eval %node_type% %node_name% -setcookie "!cookie!" "erlang:list_to_integer(os:getpid()).'
  1. using single quotes instead of backticks in
for /f "delims=" %%i in (`%%get_pid_cmd%%`) do set pid=%%i

helps.

However, there's other, more complicated issue: running foreground after process was already running returns errorlevel 0 which may be confusing. Moreover the whole foreground command now is now not really a foreground as erl process is being detached. This is opposition of being foreground.

If I add /w switch to the start command it works as expected but there's no easy way to call post start hooks without running subprocess and quite complicated procedure for detection if it hasn't died.

Is there any reason why all these scripts are not written in erlang given we have a runtime in place but instead use bash/DOS shell? Wouldn't refactoring them into erlang be useful, give much better control on what is happening and multiplatform, reusable code?

mspanc avatar Oct 18 '17 21:10 mspanc

I'm not opposed to reworking some things into escripts, but a lot of this stuff is much more flexible using shell (at least on Linux, you have the option of scripting custom commands and hooks using whatever you want, escript, bash, python, perl, etc.). The most complex stuff has to be done in shell anyway because we have to set up the environment for the runtime to run properly, once that's done, it's easy to choose between shell or an escript for most things (with the exception of custom commands/hooks, which at least on Linux I think should use shell for the flexibility).

If you have a vision of what you think it might look like though, open up an RFC issue and we can discuss it in detail (and others can chime in as well). It may well be that much of the Windows support can be done in escript rather than batch, making it less fragile.

bitwalker avatar Oct 21 '17 04:10 bitwalker

Same problem occurs on Windows 10 Enterprise:

Die Datei "`%get_pid_cmd%`" kann nicht gefunden werden. => Translation: Can't find file "`%get_pid_cmd%`".

Is there a plan fixing this issue in future?

@bitwalker The free Windows developer images might be a good choice for you: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

magynhard avatar Mar 05 '18 13:03 magynhard

Same issue a fix for this would be nice. We don't use windows but unfortunately 90% of our target audience does :(

vans163 avatar Jun 27 '18 00:06 vans163

This issue changed a bit, I'm now getting a Failed to open file: nodetool . This happens with the ping and foreground commands.

I believe I built the release with 2.0.0-rc8

nerdyworm avatar Aug 09 '18 00:08 nerdyworm

@nerdyworm Can you try with the latest on master? I just pushed a handful of fixes/changes for 2.0 for Windows specifically

bitwalker avatar Aug 14 '18 02:08 bitwalker

On master, the foreground and start command failed with

| Received 'pang' from [email protected]
| The possible reasons for this include;
|  - The cookie is mismatched bewtween us and the target node
|  - We cannot establish a remote connection to the node
ERROR: The search filter cannot be recogniced
The system cannot find the batch label specified - post_stop_hooks

failed-foreground

nerdyworm avatar Aug 14 '18 14:08 nerdyworm

@nerdyworm I made some further changes today, can you try again? I'm able to run the foreground and console commands in an administrative console with a release built with include_erts: true.

I have barely even started to look at non-admin shells, since you can't even create symlinks without admin privs out of the box, and with the way Erlang works on Windows, I'm not sure supporting include_erts: false is practical, so I haven't gone deep there yet.

Can Windows users here chime in and let me know whether batch-based releases are important to you vs building and running releases using the Windows Subsystem for Linux? After diving through the batch script to get things working these past few days, it is so utterly fragile and prone to failure due to the problems of batch scripting in general, that I'm hesitant to continue supporting it. The contributions made so far have all attempted to fix various things, and we're still in this dismal state of support. I haven't explored rewriting things in Powershell, but I'm not entirely sure whether or not we can rewrite everything in PS or not - it would certainly improve things to some degree I think if we could. If, however, WSL is stable enough to be used in production, I think everyone is better off if we discontinue the batch script support and unify our efforts under the shell scripts that everyone uses under *NIX today, they are far more reliable.

bitwalker avatar Aug 14 '18 21:08 bitwalker

Well I'm not building on windows anymore, but back on windows the linux shell scripts would be a no-go as it ran on a Windows 2008 server (no WSL), but powershell would have been fine (though the scripts need to be signed or they can't be run without enabling unsigned scripts).

OvermindDL1 avatar Aug 14 '18 22:08 OvermindDL1

@OvermindDL1 Yeah I mean, that's kinda my question. Or perhaps multiple questions:

1.) Are the bulk of Windows users looking to deploy Elixir in a situation where they can run a server OS with WSL or are they stuck on legacy boxes where WSL is either not available or cannot be installed 2.) If they aren't able to for some reason, are they willing to accept a significantly smaller subset of functionality than what is present for *NIX deployments (i.e. not supporting hooks, custom commands, eval/rpc, etc.) 3.) If the scripts were rewritten in PS to try and bring feature parity and some degree of maintainability to the scripts, is it acceptable to run unsigned scripts. If not, then PS is a no-go, which brings us back to 2

So the big question here is whether the number of users needing batch scripts is a significant portion of the Windows crowd. If it's a small percentage, I would want to know which direction to take things - unsigned PS scripts (if workable), or requiring WSL.

In my opinion, the batch script situation is untenable - they are basically unmaintainable without a significant time investment in testing every time there is a change, and debugging when things aren't working is extremely painful, which means supporting issues on Windows is very difficult. Windows, just like *NIX, needs reliability, maintainability, and easy debugging. Right now it has none of those, and the situation has to change.

bitwalker avatar Aug 14 '18 22:08 bitwalker

  1. Well in my experience over a couple of big companies, Windows Server version was always at best 1 or 2 major versions out of date (I was deploying to a 2003 server originally, but they've managed to update to 2008 in the past year here).

  2. Not really, I used that stuff... :-(

  3. PS could definitely do it, running unsigned scripts is fine but you'd probably want a bat/vbs hoist script to pass the correct arguments to PS to allow it to run the script unsigned (it's easy to do).

But as stated, I'm not deploying to Windows anymore (woooo), but that is how I would have answered in the past. :-)

And yes, bat files needs to diaf, PS is better, though still not as nice as zsh/bash shell scripts (though PS is a lot more debuggable honestly!).

OvermindDL1 avatar Aug 14 '18 22:08 OvermindDL1

Plus you can run powershell scripts on linux too, so that is much easier for you to test.

OvermindDL1 avatar Aug 14 '18 22:08 OvermindDL1

Thanks for the feedback @OvermindDL1!

I will explore the PS route a bit. Since we already have a shim script to exec the "real" boot script, it can be modified to run it as a PS script instead, the question is whether there are issues with maintaining parity with the *NIX scripts in PS or not.

I'm still interested in feedback from others in the community though, so feel free to chime in, even if just to state your agreement!

bitwalker avatar Aug 14 '18 23:08 bitwalker

@bitwalker Our use case is our users are not computer programming literate, they do not know WSL even exists. Instructing them to use it, will be a technical support nightmare. We have a daemonized app that runs when you double click it. Thats all it has to do, is run.

vans163 avatar Aug 16 '18 17:08 vans163

My use case involves a user double clicking an installer and installing the build as a window service that is controlled by erlsrv.exe.

nerdyworm avatar Aug 16 '18 17:08 nerdyworm

@vans163 @nerdyworm Thanks for chiming in! It sounds like WSL is still not a practical requirement for production apps, which is a shame given how long it's been around now, but I'm not surprised. It's a shame apps can't be built to run under WSL transparently, even as Windows services, but it is what it is.

In any case, I think the only viable path forward until WSL is more useful is to port the scripts to PS, or have a dedicated Windows maintainer who can make sure the batch scripts are up to par - it'd be nice to have someone like that either way really, since I don't work in a Windows environment anymore, I just run tests/work out kinks in a Windows 10 VM, which may not be representative of all Windows environments anyway; so if any of you are interested, or know somebody who is, definitely let me know!

bitwalker avatar Aug 16 '18 18:08 bitwalker

I'd personally recommend making the PS scripts, try to keep it to PS2 if possible but any half-updated system in the past 10 years should have at least PS4. PS will be testable on linux in large part at the very least via dotNetCore.

OvermindDL1 avatar Aug 16 '18 18:08 OvermindDL1

@OvermindDL1 Yeah some parts will for sure be testable on Linux, which is huge, one of the most complicated parts is the installation and management of the Windows service though for running as a daemon, and that part will have to be done on Windows - but even if that's a manual thing, it's a huge improvement over the current situation.

bitwalker avatar Aug 16 '18 18:08 bitwalker

one of the most complicated parts is the installation and management of the Windows service though for running as a daemon, and that part will have to be done on Windows - but even if that's a manual thing, it's a huge improvement over the current situation.

It would not surprise me in the least if .NET had an easy way to register such a service, which a PS script could access, so that might be a well documented pattern out there.

OvermindDL1 avatar Aug 16 '18 18:08 OvermindDL1

Well ultimately that's what erlsrv is for, so it takes care of most of that - maybe complexity wasn't the right word, more that it is prone to issues if not under automated tests - it requires elevated permissions, and error handling around that needs to be robust to better guide users around that (error handling in general needs improvement on Windows). Most of the other tasks can either run unelevated, or are executed very closely to the way they are on Linux, leading to more predictable behavior - running as a daemon differs the most between Linux and Windows vs all other modes.

bitwalker avatar Aug 16 '18 19:08 bitwalker

I've rewritten all of the Windows scripts in Powershell. It's better if you can run Powershell Core/6+, since I can easily test many things on my macbook with Powershell Core, but I have tested it with Powershell 5.1. The foreground, install, uninstall, start, stop, help, describe, and eval commands have all been tested. There are a few others implemented which are more or less identical to ones I've tested, and a few others I haven't yet implemented, namely upgrade and downgrade - but I'd recommend anyone running Windows to please test out what is in master right now so I can make any necessary fixes ASAP.

bitwalker avatar Sep 01 '18 23:09 bitwalker