Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bat files containing typos & hot upgrade not working #391

Closed
oboudry opened this issue Jan 24, 2018 · 3 comments
Closed

bat files containing typos & hot upgrade not working #391

oboudry opened this issue Jan 24, 2018 · 3 comments
Labels
bug Things flat out don't work, or we said they would work one way but they work another deployment:scripts Anything to do with the management scripts help-wanted I need help in order to get this addressed sooner rather than later os:windows Issue is specific to Windows
Milestone

Comments

@oboudry
Copy link

oboudry commented Jan 24, 2018

Error when doing a hot upgrade of a running application. I'm following step by step the Distillery chapter of the Elixir Programming 1.6 book.

Platform: Erlang 20 erts-9.2 64-bits on Windows 7, with Elixir 1.6.

Steps to reproduce

> mix release.init
>     mix release --env=prod
>     # unzip tar.gz release 0.1.0 into a separate folder
>     bin/sequence console
# make some changes
> mix release --env=prod --upgrade
# move tar.gz release 0.2.0 into corresponding folder
> bin/sequence upgrade 0.2.0
escript failed to open file /bin/release_utils.escript
### Verbose Logs

Description of issue

I'm not through yet, but found a number of bugs in the sequence.bat files found in releases/x.y.z/.bat

The script fails to run, and unfortunately exits without giving time to read the error messages. A goto :eof would be better than exit, also I understand exit is important for automation. Maybe a debug option not exiting.

Errors found so far:

  • A badly named variable %root_dir% instead of %release_root_dir%
  • A missing % at the end of a %release_root_dir variable
  • goto tags don't work if file format is not CRLF (dos)
  • if statements contains EXISTS when it should be EXIST, and DO that are not supported.

`diff --git a/erts-9.2/bin/erl.ini b/erts-9.2/bin/erl.ini
index 805f6e3..97f37e6 100644
--- a/erts-9.2/bin/erl.ini
+++ b/erts-9.2/bin/erl.ini
@@ -1,4 +1,4 @@
-[erlang]
-Bindir=C:\Program Files\erl9.2\erts-9.2\bin
-Progname=erl
-Rootdir=C:\Program Files\erl9.2
+[erlang]
+Bindir=C:\Users\obou\Dropbox\Code\Elixir\Programming_Elixir_1.6\deploy2
\erts-9.2\bin
+Progname=erl.exe
+Rootdir=C:\Users\obou\Dropbox\Code\Elixir\Programming_Elixir_1.6\deploy2

diff --git a/releases/0.1.0/sequence.bat b/releases/0.1.0/sequence.bat
index 38fdd92..9787502 100644
--- a/releases/0.1.0/sequence.bat
+++ b/releases/0.1.0/sequence.bat
@@ -307,17 +307,17 @@
@set source_version=%rel_vsn%
@set target_version=%args%
:: Unpack
-@%escript% "%root_dir%\bin\release_utils.escript" ^
+@%escript% "%release_root_dir%\bin\release_utils.escript" ^
unpack_release %rel_name% "%node_type%" "%node_name%" "!cookie!" "%target_v
ersion%"
@if %ERRORLEVEL% GEQ 1 exit %ERRORLEVEL%
:: Update env
@set rel_vsn=%target_version%
-@set rel_dir=%release_root_dir\releases%target_version%
+@set rel_dir=%release_root_dir%\releases%target_version%
:: TODO: init_configs
-if exists "%rel_dir%\sys.config.bak" do (
+if exist "%rel_dir%\sys.config.bak" (
@Move /Y "%rel_dir%\sys.config.bak" "%rel_dir%\sys.config"
)
-if exists "%rel_dir%\vm.args.bak" do (
+if exist "%rel_dir%\vm.args.bak" (
@Move /Y "%rel_dir%\vm.args.bak" "%rel_dir%\vm.args"
)
@copy /B /Y "%rel_dir%/sys.config" "%rel_dir%\sys.config.bak"
`

I fixed all of these but it's still not working, will update ticket if I find more errors.

@oboudry
Copy link
Author

oboudry commented Jan 25, 2018

One more thing that would be great is changing all the exit # commands where # is the exit code into exit /b #
In MS-DOS, exit will close not only the batch file running, but also the terminal that was used to start the batch file. This makes troubleshooting impossible as error messages cannot be run. It's also certainly not the intended effect.

@oboudry
Copy link
Author

oboudry commented Jan 25, 2018

I've used the hex package, and I realize that cloning the latest version solves a lot of these. Sorry for that beginner error, I should have started that way. I retried it with latest cloned version, and now I can do the in place upgrade. It works and the running app shows the new behaviour, but the in place upgrade returns an error after the release is installed.

C:\Users\obou\Dropbox\Code\Elixir\Programming_Elixir_1.6\deploy>bin\sequence upgrade 0.2.0
Release 0.2.0 not found, attempting to unpack releases/0.2.0/sequence.tar.gz
Unpacked successfully: "0.2.0"
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
        0 file(s) copied.
Release 0.2.0 is already unpacked, now installing.
Installed Release: 0.2.0
escript: exception error: no match of right hand side value
                 {error,{service_update_failed,service_name_missmatch}}

C:\Users\obou\Dropbox\Code\Elixir\Programming_Elixir_1.6\deploy>

@bitwalker bitwalker added bug Things flat out don't work, or we said they would work one way but they work another os:windows Issue is specific to Windows deployment:scripts Anything to do with the management scripts labels Mar 10, 2018
@bitwalker bitwalker added this to the 2.0 milestone Mar 10, 2018
@bitwalker bitwalker added the help-wanted I need help in order to get this addressed sooner rather than later label Mar 12, 2018
@bitwalker
Copy link
Owner

Closing due to inactivity. For those still having issues, please open new issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things flat out don't work, or we said they would work one way but they work another deployment:scripts Anything to do with the management scripts help-wanted I need help in order to get this addressed sooner rather than later os:windows Issue is specific to Windows
Projects
None yet
Development

No branches or pull requests

2 participants