schnittchen/carafe

Elixir deploy

Closed this issue · 14 comments

have error when start deploy
00:11 buildhost:prepare_build_path
01 sh -c git\ -C\ /home/property/my_app/cache\ archive\ 0d598d6a206940d9709a8939836ea6f4aa570118\ |\ tar\ xfC\ -\ /home/property/my_app/build
01 Unknown option: -C
01 usage: git [--version] [--help] [-c name=value]
01 [--exec-path[=]] [--html-path] [--man-path] [--info-path]
01 [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
01 [--git-dir=] [--work-tree=] [--namespace=]
01 []
01 tar: This does not look like a tar archive
01 tar: Exiting with failure status due to previous errors
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as property@web2.3taps.com: sh exit status: 2
sh stdout: Nothing written
sh stderr: Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[]
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

Caused by:
SSHKit::Command::Failed: sh exit status: 2
sh stdout: Nothing written
sh stderr: Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[]

my config
server "web2", user: "property", roles: ["build"]

set :application, "posting_matcher"
set :repo_url, "git"
set :mix_env, :prod
set :distillery_release, "posting_patcher"

set :repo_path, "/home/property/my_app/cache"
set :build_path, "/home/property/my_app/build"
set :app_path, "/home/property/my_app"

Can you log into your server and check your git version please?

At first glance it looks like the "-C" flag is not supported.

git version 1.8.3.1

update helped. But have another issue. How i can copy config
00:13 buildhost:mix:deps.get
01 mix local.hex --force
01 ** (Mix.Config.LoadError) could not load config apps/deletion_scraper/config/prod.secret.exs
01 ** (File.Error) could not read file "/home/property/my_app/build/apps/deletion_scraper/config/prod.secret.exs": no such file or directory

I don't know what git version is required, but 1.8 is pretty old. Carafe is pretty new and I am not inclined to support old versions of git (or elixir, ...).

It looks like you are missing your prod.secrets.exs, which is usually gitignored (since it is intended for secrets not to be checked into the git repository). You can either take the risk and check it in, or add a build step to add the file before compilation. This is not a solved problem as of now, because the way this file will be written depends much on the individual case.

Does your prod.secrets.exs actually contain anything useful? If yes, I suggest you add a secrets file with bogus values for now, in order to see what other things work or don't work for you. Once everything else is fine, we need to find a way to add the secrets at the right step. Otherwise, just remove the inclusion of the file from confix/prod.exs and you should be good.

find solution with prod.secrets.exs
`
task :copy_configs do
on build_host do |host|

execute "ln -s /home/property/config/deletion_scraper/prod.secret.exs #{build_path}/apps/deletion_scraper/config/prod.secret.exs"

end
end
`

after 'buildhost:prepare_build_path', :copy_configs

and after that build create successfully. But have another problem
buildhost:archive:download
Downloading archive.tar.gz 10.15%
Downloading archive.tar.gz 20.01%
Downloading archive.tar.gz 30.07%
Downloading archive.tar.gz 40.12%
Downloading archive.tar.gz 50.18%
Downloading archive.tar.gz 60.04%
Downloading archive.tar.gz 70.09%
Downloading archive.tar.gz 80.15%
Downloading archive.tar.gz 90.01%
Downloading archive.tar.gz 100.0%
(Backtrace restricted to imported tasks)
cap aborted!
No hosts have been configured with role 'app'

Resolved by added roles app. Final step

node:full_restart
01 cd /home/property/my_app; for i in {1..10}; do bin/posting_matcher ping && break || true; sleep 1; done
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
01 Node 'posting_matcher@127.0.0.1' not responding to pings.
✔ 01 property@server 18.553s
02 bin/posting_matcher rpc Elixir.Carafe execute_elixir '
'\ \ \ \ \ \ \ \ fn\ ->\ Application.started_applications\ |>\ Enum.any?(fn\ info\ ->\ elem(info,\ 0)\ ==\ :posting_matcher\ end)\ end'…
02 Node posting_matcher@127.0.0.1 is not running!
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as property@server: bin/posting_matcher exit status: 1
bin/posting_matcher stdout: Node posting_matcher@127.0.0.1 is not running!
bin/posting_matcher stderr: Nothing written

Caused by:
SSHKit::Command::Failed: bin/posting_matcher exit status: 1
bin/posting_matcher stdout: Node posting_matcher@127.0.0.1 is not running!
bin/posting_matcher stderr: Nothing written

looks like server is started and responded but steel have error on end deploy

node:full_restart
01 cd /home/property/my_app; for i in {1..10}; do bin/posting_matcher ping && break || true; sleep 1; done
01 pong
✔ 01 property@server 1.179s
02 bin/posting_matcher rpc Elixir.Carafe execute_elixir '
'\ \ \ \ \ \ \ \ fn\ ->\ Application.started_applications\ |>\ Enum.any?(fn\ info\ ->\ elem(info,\ 0)\ ==\ :posting_matcher\ end)\ end'…
02 RPC to 'posting_matcher@127.0.0.1' failed: {'EXIT',
02 {undef,
02 [{'Elixir.Carafe',
02 execute_elixir,
02 ["\n fn -> Application.started_applications |> Enum.any?(fn info -> elem(info, 0) == :posting_matcher end) end\n |> Stream.repeatedly\n …
02 []},
02 {rpc,
02 '-handle_call_call/6-fun-0-',5,
02 [{file,"rpc.erl"},
02 {line,197}]}]}}
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as property@server bin/posting_matcher exit status: 1
bin/posting_matcher stdout: RPC to 'posting_matcher@127.0.0.1' failed: {'EXIT',
{undef,
[{'Elixir.Carafe',
execute_elixir,
["\n fn -> Application.started_applications |> Enum.any?(fn info -> elem(info, 0) == :posting_matcher end) end\n |> Stream.repeatedly\n |> Stream.each(fn running -> unless running, do: :timer.sleep(250) end)\n |> Enum.any?\n "],
[]},
{rpc,
'-handle_call_call/6-fun-0-',5,
[{file,"rpc.erl"},
{line,197}]}]}}
bin/posting_matcher stderr: Nothing written

Caused by:
SSHKit::Command::Failed: bin/posting_matcher exit status: 1
bin/posting_matcher stdout: RPC to 'posting_matcher@127.0.0.1' failed: {'EXIT',
{undef,
[{'Elixir.Carafe',
execute_elixir,
["\n fn -> Application.started_applications |> Enum.any?(fn info -> elem(info, 0) == :posting_matcher end) end\n |> Stream.repeatedly\n |> Stream.each(fn running -> unless running, do: :timer.sleep(250) end)\n |> Enum.any?\n "],
[]},
{rpc,
'-handle_call_call/6-fun-0-',5,
[{file,"rpc.erl"},
{line,197}]}]}}
bin/posting_matcher stderr: Nothing written

Is your node running? Can you attach to it? If so, is Carafe loaded, does iex autocomplete when you type Car?

yes, node is running and works good. I do not understand what you mean
is Carafe loaded, does iex autocomplete when you type Car?

Can you attach to the running node and see an IEx shell? in there, what does i Carafe return?

MIX_ENV=prod iex -S mix phx.server
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:10] [hipe] [kernel-poll:false]

09:22:03.354 [info] Running PostingMatcherWeb.Endpoint with Cowboy using http://0.0.0.0:4001
Don`t see any errors...

It looks like you just started your application through mix locally. In production, you use distillery through carafe to deploy a release. The error above ({'EXIT', {undef, [{'Elixir.Carafe',...) indicates your release might not contain carafe. To verify this, I would like you to interact with the app running from the release, not through mix.

Can you try to attach to your running node with bundle exec cap production node:attach? If yes, what does i Carafe give you?

You right. I have umbrella apps. Carafe was added only to main mix.exs When i added carafe to umbrella project deploy was successfully . Thanks

Nice you got it working!