Closed IdahoEv closed 7 years ago
Hi Evan, thanks for the feedback!
What does your /etc/init.d/tracker
file on the server contain?
Can you open up iex
on the server and execute these four lines from the Utilities.available_port/0 function manually? What do you get?
@dennisreimann Thanks for the quick reply!
The /etc/init.d/tracker and /etc/nginx/sites-enabled/tracker files both contain the port number, see below. I've been able to get the site up by inspecting them to get the port number and then running the release directly (PORT=39491 sudo --preserve-env _build/prod/rel/tracker/bin/tracker start
). I just can't do it by running mix gatling.deploy
: that's what results in the above error.
Will try executing those lines manually and post a follow-up.
/etc/init.d/tracker:
~$ cat /etc/init.d/tracker
#!/bin/sh
### BEGIN INIT INFO
# Provides: tracker
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Plug Application: tracker
### END INIT INFO
export MIX_ENV=prod
export PORT=39491
export HOME=/home/deploy/deployments/tracker
/etc/nginx/sites-enabled/tracker
$ cat /etc/nginx/sites-enabled/tracker
server {
listen 80;
server_name <MYAPP>;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:39491;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
I have to provide a port at the command line to load the app in iex (else I get the same error as above) but once I do the function you linked seems to be able to identify a port just fine:
~/tracker$ PORT=39492 iex -S mix
Erlang/OTP 19 [erts-8.2] [source-fbd2db2] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
01:54:49.612 [info] Running Tracker.Endpoint with Cowboy using http://localhost:39492
Interactive Elixir (1.4.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Gatling.Utilities
Gatling.Utilities
iex(2)> Gatling.Utilities.available_port
38454
I'm going to add an issue about the other problem I'm having, in case it's related.
I didn't mean to boot up the app with iex. Just start a normal iex session without any params outside the project folder and see whether or not getting the port number works :)
The reason I booted the app is that (ashamed to admit this) I didn't otherwise know how to load an external library in an iex session. This morning I figured it out, though, so here you go:
deploy@my-app:~$ iex
Erlang/OTP 19 [erts-8.2] [source-fbd2db2] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (1.4.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Code.append_path "/home/deploy/.mix/archives/gatling/gatling/ebin/"
true
iex(2)> Gatling.Utilities.available_port
36296
The port number isn't the same as what in nginx config, but I assume that's because the app is currently running, so 39491 is no longer available.
I tried a complete re-set today, deleting all relevant files on the server and starting over with a fresh install of gatling. I'm sorry this is so long -- but since we're 9 hours apart i thought it would reduce iteration time to include everything. Here are my config files, and I'll put the transcript of my attempt to deploy in the next post.
Interestingly: the site actually came up, despite the errors, which were the same as before. however I wasn't able to deploy an upgrade because the git repo on the server was left with uncommitted local changes to mix.lock.
config/config.exs
use Mix.Config
# General application configuration
config :tracker,
ecto_repos: [Tracker.Repo]
# Configures the endpoint
config :tracker, Tracker.Endpoint,
url: [host: "localhost"],
secret_key_base: "... SNIP ...",
render_errors: [view: Tracker.ErrorView, accepts: ~w(html json)],
pubsub: [name: Tracker.PubSub,
adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
import_config "#{Mix.env}.exs"
config/prod.exs
config :tracker, Tracker.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "my-app.org", port: 80],
cache_static_manifest: "priv/static/manifest.json",
root: ".",
server: true,
version: Mix.Project.config[:version]
# Do not print debug messages in production
config :logger, level: :info
config :tracker, Tracker.Endpoint,
secret_key_base: System.get_env("SECRET_KEY_BASE")
config :tracker, Tracker.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.get_env("DB_USERNAME"),
password: System.get_env("DB_PASSWORD"),
database: System.get_env("DB_DATABASE"),
hostname: System.get_env("DB_HOSTNAME"),
pool_size: 20
# This line appears further down. Do not forget to uncomment it!
config :phoenix, :serve_endpoints, true
rel/config.exs
# 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,
default_release: :default,
default_environment: :prod
environment :dev do
set dev_mode: true
set include_erts: false
set cookie: :"... SNIP ..."
end
environment :prod do
set include_erts: true
set include_src: false
set cookie: :"#:{:crypto.hash(:sha256, System.get_env(\"COOKIE\"))}"
end
release :tracker do
set version: current_version(:tracker)
end
deploy.exs
defmodule Tracker.DeployCallbacks do
import Gatling.Bash
def before_mix_digest(env) do
# mkdir prevents complains about this directory not existing
bash("mkdir", ~w[-p priv/static], cd: env.build_dir)
bash("npm", ~w[install], cd: env.build_dir)
bash("npm", ~w[run deploy], cd: env.build_dir)
end
end
upgrade.exs
defmodule Tracker.UpgradeCallbacks do
import Gatling.Bash
def before_mix_digest(env) do
bash("npm", ~w[install], cd: env.build_dir)
bash("npm", ~w[run deploy], cd: env.build_dir)
end
def before_upgrade_service(env) do
bash("mix", ~w[ecto.migrate], cd: env.build_dir)
end
end
Okay, here's the complete transcript of my attempt to deploy today, which had the same errors as yesterday. Despite the errors the site actually came up the first time, though when I try to push an update the changes do not get deployed.
ON SERVER: rename all relevant files and reboot
deploy@my-app:~$ mkdir disabled
deploy@my-app:~$ sudo mv tracker/ disabled/
deploy@my-app:~$ sudo mv .hex/ disabled/
deploy@my-app:~$ sudo mv deployments/ disabled/
deploy@my-app:~$ sudo mv .mix disabled/
deploy@my-app:~$ sudo mv /etc/init.d/tracker disabled/init.d-tracker
deploy@my-app:~$ sudo mv /etc/nginx/sites-available/tracker disabled/nginx-site-tracker
deploy@my-app:~$ sudo reboot
ON SERVER: reconnect after reboot, confirm environment vars are correct, install gatling and initialize the repo
Last login: Sun Jan 22 16:11:37 2017 from 24.205.139.1
deploy@my-app:~$ echo $MIX_ENV
prod
deploy@my-app:~$ echo $SECRET_KEY_BASE
... SNIP ...
deploy@my-app:~$ echo $DB_HOSTNAME
localhost
deploy@my-app:~$ echo $DB_DATABASE
myapp_prod
deploy@my-app:~$ echo $DB_USERNAME
myapp
deploy@my-app:~$ echo $DB_PASSWORD
... SNIP ...
deploy@my-app:~$ echo $COOKIE
... SNIP ...
deploy@my-app:~$ mix archive.install https://github.com/hashrocket/gatling_archives/raw/master/gatling.ez
Are you sure you want to install archive "https://github.com/hashrocket/gatling_archives/raw/master/gatling.ez"? [Yn]
* creating .mix/archives/gatling
deploy@my-app:~$ mix local.hex
Are you sure you want to install archive "https://repo.hex.pm/installs/1.3.0/hex-0.15.0.ez"? [Yn] Y
* creating .mix/archives/hex-0.15.0
deploy@my-app:~$ mix local.rebar
* creating .mix/rebar
* creating .mix/rebar3
deploy@my-app:~$ mix gatling.load tracker
Created /home/deploy/tracker
$ git init /home/deploy/tracker
Initialized empty Git repository in /home/deploy/tracker/.git/
$ git config receive.denyCurrentBranch updateInstead (/home/deploy/tracker)
Created /home/deploy/deployments/tracker
deploy@my-app:~$
ON LOCAL MACHINE: attempt first push. Get error about inability to find .rel file, (same as #39)
[09:47:53 tracker (master)]$ git push production master
Counting objects: 438, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (409/409), done.
Writing objects: 100% (438/438), 1.21 MiB | 0 bytes/s, done.
Total 438 (delta 168), reused 0 (delta 0)
remote: $ mix deps.get (/home/deploy/tracker)
remote: Running dependency resolution...
remote: * Getting phoenix (Hex package)
remote: Checking package (https://repo.hex.pm/tarballs/phoenix-1.2.1.tar)
remote: Fetched package
[ ... snip packages ...]
remote: $ mix compile --force (/home/deploy/tracker)
[ ... snip dependency compiles ...]
remote: ==> tracker
remote: Compiling 15 files (.ex)
remote: warning: variable "timestamps" does not exist and is being expanded to "timestamps()", please use parentheses to remove the ambiguity or change the variable name
remote: web/models/item.ex:14
remote:
remote: Generated tracker app
remote: $ npm install (/home/deploy/tracker)
remote: npm WARN prefer global coffee-script@1.10.0 should be installed with -g
remote: /home/deploy/tracker
remote: ├─┬ babel-brunch@6.0.6
[ ... snip npm tree ...]
remote:
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
remote: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
remote: $ npm run deploy (/home/deploy/tracker)
remote:
remote: > @ deploy /home/deploy/tracker
remote: > brunch build --production
remote:
remote: 22 Jan 17:50:31 - info: compiling
remote: 22 Jan 17:50:35 - info: compiling.
remote: 22 Jan 17:50:35 - info: compiled 10 files into 2 files, copied 5 in 8.9 sec
remote: $ mix phoenix.digest (/home/deploy/tracker)
remote: Check your digested files at "priv/static"
remote: /home/deploy/tracker/rel/config.exs found
remote: $ mix release --upgrade --upfrom= --warnings-as-errors --env=prod (/home/deploy/tracker)
remote: ==> Assembling release..
remote: ==> Building release tracker:0.1.2 using environment prod
remote: ==> Upgrade from to 0.1.2 failed:
remote: does not exist at _build/prod/rel/tracker/releases
remote: ==> Failed to build release:
remote: :bad_upgrade_spec
remote: ** (File.CopyError) could not copy from "/home/deploy/tracker/_build/prod/rel/tracker/releases/0.1.2/tracker.tar.gz" to "/home/deploy/deployments/tracker/releases/0.1.2/tracker.tar.gz": no such file or directory
remote: (elixir) lib/file.ex:524: File.cp!/3
remote: lib/gatling/tasks/upgrade.ex:102: Mix.Tasks.Gatling.Upgrade.copy_release_to_upgrade/1
remote: lib/gatling/tasks/upgrade.ex:123: Mix.Tasks.Gatling.Upgrade.call/2
remote: lib/gatling/tasks/upgrade.ex:33: Mix.Tasks.Gatling.Upgrade.upgrade/1
remote: (mix) lib/mix/task.ex:294: Mix.Task.run_task/3
remote: (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
remote:
To deploy@myapp.org:tracker
* [new branch] master -> master
BACK ON SERVER : See that _build/prod/rel/tracker/releases directory has not been created. Run gatling.deploy, get error about port being nil
deploy@my-app:~$ tree -L 2 tracker/_build/
tracker/_build/
└── prod
├── consolidated
└── lib
3 directories, 0 files
deploy@my-app:~$ sudo --preserve-env mix gatling.deploy tracker
$ mix deps.get (/home/deploy/tracker)
Running dependency resolution...
All dependencies up to date
$ mix compile --force (/home/deploy/tracker)
Compiling 15 files (.ex)
warning: variable "timestamps" does not exist and is being expanded to "timestamps()", please use parentheses to remove the ambiguity or change the va$iable name
web/models/item.ex:14
Generated tracker app
$ mkdir -p priv/static (/home/deploy/tracker)
$ npm install (/home/deploy/tracker)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","a$ch":"x64"})
$ npm run deploy (/home/deploy/tracker)
> @ deploy /home/deploy/tracker
> brunch build --production
22 Jan 17:55:18 - info: compiling
22 Jan 17:55:22 - info: compiling.
22 Jan 17:55:22 - info: compiled 10 files into 2 files, copied 5 in 9 sec
$ mix phoenix.digest (/home/deploy/tracker)
Check your digested files at "priv/static"
/home/deploy/tracker/rel/config.exs found
$ mix release --warnings-as-errors --env=prod (/home/deploy/tracker)
==> Assembling release..
==> Building release tracker:0.1.2 using environment prod
==> Including ERTS 8.2 from /usr/lib/erlang/erts-8.2
==> Packaging release..
==> Release successfully built!
You can run it in one of the following ways:
Interactive: _build/prod/rel/tracker/bin/tracker console
Foreground: _build/prod/rel/tracker/bin/tracker foreground
Daemon: _build/prod/rel/tracker/bin/tracker start
$ tar -xf tracker.tar.gz (/home/deploy/deployments/tracker)
$ update-rc.d tracker defaults
$ mix ecto.setup (/home/deploy/tracker)
The database for Tracker.Repo has already been created
17:55:32.327 [info] Already up
17:55:32.477 [info] Application tracker exited: Tracker.start(:normal, []) returned an error: shutdown: failed to start child: Tracker.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) an exception was raised:
** (RuntimeError) server can't start because :port in config is nil, please use a valid port number
(phoenix) lib/phoenix/endpoint/server.ex:31: Phoenix.Endpoint.Server.to_port/1
(phoenix) lib/phoenix/endpoint/server.ex:28: Phoenix.Endpoint.Server.default/3
(phoenix) lib/supervisor.ex:17: anonymous fn/5 in Phoenix.Endpoint.Server.init/1
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/supervisor.ex:15: Phoenix.Endpoint.Server.init/1
(stdlib) supervisor.erl:294: :supervisor.init/1
(stdlib) gen_server.erl:328: :gen_server.init_it/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
{"Kernel pid terminated",application_controller,"{application_start_failure,tracker,{{shutdown,{failed_to_start_child,'Elixir.Tracker.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoint.Server',{#{'__exception__' => true,'__struct__' => 'Elixir.RuntimeError',message => <<\"server can't start because :port in config is nil, please use a valid port number\">>},[{'Elixir.Phoenix.Endpoint.Server',to_port,1,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,31}]},{'Elixir.Phoenix.Endpoint.Server',default,3,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,28}]},{'Elixir.Phoenix.Endpoint.Server','-init/1-fun-0-',5,[{file,\"lib/supervisor.ex\"},{line,17}]},{'Elixir.Enum','-reduce/3-lists^foldl/2-0-',3,[{file,\"lib/enum.ex\"},{line,1755}]},{'Elixir.Phoenix.Endpoint.Server',init,1,[{file,\"lib/supervisor.ex\"},{line,15}]},{supervisor,init,1,[{file,\"supervisor.erl\"},{line,294}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}}}},{'Elixir.Tracker',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tracker,{{shutdown,{failed_to_start_child,'Elixir.Tracker.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoint
Crash dump is being written to: erl_crash.dump...done
$ service tracker start
$ nginx -s reload
At this point, I discovered to my surprise that the app was actually running and I could load it in browser.
On server, inspect the nginx and init.d files that were created
deploy@my-app:~$ sudo cat /etc/init.d/tracker
#!/bin/sh
### BEGIN INIT INFO
# Provides: tracker
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Plug Application: tracker
### END INIT INFO
export MIX_ENV=prod
export PORT=51528
export HOME=/home/deploy/deployments/tracker
export $(cat /home/deploy/deployments/tracker/.env)
/home/deploy/deployments/tracker/bin/tracker "$1" "$2"
deploy@my-app:~$ sudo cat /etc/nginx/sites-available/tracker
server {
listen 80;
server_name myapp.org;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:51528;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
ON SERVER: Inspect the build the that was generated by gatling.deploy
deploy@my-app:~$ tree -L 2 tracker/_build/prod/rel/tracker/releases/
tracker/_build/prod/rel/tracker/releases/
├── 0.1.2
│ ├── commands
│ ├── hooks
│ ├── start_clean.boot
│ ├── sys.config
│ ├── tracker.boot
│ ├── tracker.rel
│ ├── tracker.script
│ ├── tracker.sh
│ ├── tracker.tar.gz
│ └── vm.args
├── RELEASES
└── start_erl.data
3 directories, 10 files
deploy@my-app:~$ sudo service tracker
cat: /home/deploy/deployments/tracker/.env: No such file or directory
export HOME='/home/deploy/deployments/tracker'
export LANG='en_US.UTF-8'
export LANGUAGE=''
export LC_ADDRESS=''
export LC_ALL=''
export LC_COLLATE=''
export LC_CTYPE=''
export LC_IDENTIFICATION=''
export LC_MEASUREMENT=''
export LC_MESSAGES=''
export LC_MONETARY=''
export LC_NAME=''
export LC_NUMERIC=''
export LC_PAPER=''
export LC_TELEPHONE=''
export LC_TIME=''
export MIX_ENV='prod'
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin'
export PORT='51528'
export PWD='/'
export TERM='screen'
Usage: tracker {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|pingpeer|console|console_clean|console_boot <file>|attach|remote_console|upgrade|downgrade|install|escript|rpc|rpcterms|eval|command <module> <function> <args>}|describe
ON LOCAL, I wanted to test deploying a change so I tweaked a couple things and bumped version number. Deploy was rejected because there were uncommitted changes in the git repo.
[10:03:38 tracker (master)]$ git push production master
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 902 bytes | 0 bytes/s, done.
Total 8 (delta 5), reused 0 (delta 0)
To deploy@myapp.org:tracker
! [remote rejected] master -> master (Working directory has unstaged changes)
error: failed to push some refs to 'deploy@myapp.org:tracker'
ON SERVER, see what the uncommitted changes were
deploy@my-app:~$ cd tracker/
deploy@my-app:~/tracker$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: mix.lock
no changes added to commit (use "git add" and/or "git commit -a")
deploy@my-app:~/tracker$ git diff
diff --git a/mix.lock b/mix.lock
index aea83c9..2f7226f 100644
--- a/mix.lock
+++ b/mix.lock
@@ -1,5 +1,5 @@
%{"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
- "cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
+ "cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
"csv": {:hex, :csv, "1.4.4", "992f2e1418849a326fd1d9287801fa2d86091db4f9611f60781da6d236f64cd4", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, optional: false]}]},
"db_connection": {:hex, :db_connection, "1.1.0", "b2b88db6d7d12f99997b584d09fad98e560b817a20dab6a526830e339f54cdb3", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
ON SERVER: attempt to clean up the deploy with release.clean so I can re-deploy
deploy@my-app:~/tracker$ sudo mix release.clean
==> Building release tracker:0.1.2 using environment dev
==> One or more direct or transitive dependencies are missing from
:applications or :included_applications, they will not be included
in the release:
:distillery
This can cause your application to fail at runtime. If you are sure
that this is not an issue, you may ignore this warning.
==> Cleaning last release..
Removing release tracker:0.1.2
==> One or more direct or transitive dependencies are missing from
:applications or :included_applications, they will not be included
in the release:
:distillery
This can cause your application to fail at runtime. If you are sure
that this is not an issue, you may ignore this warning.
==> Clean successful!
ON SERVER: reset the git repository so I can push again
deploy@my-app:~/tracker$ git reset --hard HEAD
HEAD is now at 3487b5f Reduce domains to 1
ON LOCAL: Push the updated version
[10:12:02 tracker (master)]$ git push -f production master
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 902 bytes | 0 bytes/s, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: $ mix deps.get (/home/deploy/tracker)
remote: Running dependency resolution...
remote: All dependencies up to date
remote: $ mix compile --force (/home/deploy/tracker)
remote: Compiling 15 files (.ex)
remote: warning: variable "timestamps" does not exist and is being expanded to "timestamps()", please use parentheses to remove the ambiguity or change the variable name
remote: web/models/item.ex:14
remote:
remote: Generated tracker app
remote: $ npm install (/home/deploy/tracker)
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
remote: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
remote: $ npm run deploy (/home/deploy/tracker)
remote:
remote: > @ deploy /home/deploy/tracker
remote: > brunch build --production
remote:
remote: 22 Jan 18:12:38 - info: compiling
remote: 22 Jan 18:12:43 - info: compiling.
remote: 22 Jan 18:12:43 - info: compiled 10 files into 2 files, copied 9 in 9 sec
remote: $ mix phoenix.digest (/home/deploy/tracker)
remote: Check your digested files at "priv/static"
remote: /home/deploy/tracker/rel/config.exs found
remote: $ mix release --upgrade --upfrom= --warnings-as-errors --env=prod (/home/deploy/tracker)
remote: ==> Assembling release..
remote: ==> Building release tracker:0.1.3 using environment prod
remote: ==> Including ERTS 8.2 from /usr/lib/erlang/erts-8.2
remote: ==> Failed to build release:
remote: Missing .rel for tracker: at _build/prod/rel/tracker/releases/tracker.rel
remote: ** (File.CopyError) could not copy from "/home/deploy/tracker/_build/prod/rel/tracker/releases/0.1.3/tracker.tar.gz" to "/home/deploy/deployments/tracker/releases/0.1.3/tracker.tar.gz": no such file or directory
remote: (elixir) lib/file.ex:524: File.cp!/3
remote: lib/gatling/tasks/upgrade.ex:102: Mix.Tasks.Gatling.Upgrade.copy_release_to_upgrade/1
remote: lib/gatling/tasks/upgrade.ex:123: Mix.Tasks.Gatling.Upgrade.call/2
remote: lib/gatling/tasks/upgrade.ex:33: Mix.Tasks.Gatling.Upgrade.upgrade/1
remote: (mix) lib/mix/task.ex:294: Mix.Task.run_task/3
remote: (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
remote:
To deploy@myapp.org:tracker
3487b5f..1a89daf master -> master
BACK ON SERVER: releases dir no longer exists, I guess I misunderstood release.clean :-(
deploy@my-app:~/tracker$ tree -L 2 tracker/_build/prod/rel/tracker/releases/
tracker/_build/prod/rel/tracker/releases/ [error opening dir]
0 directories, 0 files
deploy@my-app:
ON SEVER: deploy again to recreate releases directory
deploy@my-app:~/tracker$ sudo --preserve-env mix gatling.deploy tracker
$ mix deps.get (/home/deploy/tracker)
Running dependency resolution...
All dependencies up to date
$ mix compile --force (/home/deploy/tracker)
Compiling 15 files (.ex)
warning: variable "timestamps" does not exist and is being expanded to "timestamps()", please use parentheses to remove the ambiguity or change the va$iable name
web/models/item.ex:14
Generated tracker app
$ mkdir -p priv/static (/home/deploy/tracker)
$ npm install (/home/deploy/tracker)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","a$ch":"x64"})
$ npm run deploy (/home/deploy/tracker)
> @ deploy /home/deploy/tracker
> brunch build --production
22 Jan 18:15:14 - info: compiling
22 Jan 18:15:18 - info: compiling.
22 Jan 18:15:18 - info: compiled 10 files into 2 files, copied 9 in 8.9 sec
$ mix phoenix.digest (/home/deploy/tracker)
Check your digested files at "priv/static"
/home/deploy/tracker/rel/config.exs found
$ mix release --warnings-as-errors --env=prod (/home/deploy/tracker)
==> Assembling release..
==> Building release tracker:0.1.3 using environment prod
==> Including ERTS 8.2 from /usr/lib/erlang/erts-8.2
==> Packaging release..
==> Release successfully built!
You can run it in one of the following ways:
Interactive: _build/prod/rel/tracker/bin/tracker console
Foreground: _build/prod/rel/tracker/bin/tracker foreground
Daemon: _build/prod/rel/tracker/bin/tracker start
$ tar -xf tracker.tar.gz (/home/deploy/deployments/tracker)
/etc/init.d/tracker already exists
$ mix ecto.setup (/home/deploy/tracker)
The database for Tracker.Repo has already been created
18:15:28.355 [info] Already up
18:15:28.497 [info] Application tracker exited: Tracker.start(:normal, []) returned an error: shutdown: failed to start child: Tracker.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) an exception was raised:
** (RuntimeError) server can't start because :port in config is nil, please use a valid port number
(phoenix) lib/phoenix/endpoint/server.ex:31: Phoenix.Endpoint.Server.to_port/1
(phoenix) lib/phoenix/endpoint/server.ex:28: Phoenix.Endpoint.Server.default/3
(phoenix) lib/supervisor.ex:17: anonymous fn/5 in Phoenix.Endpoint.Server.init/1
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/supervisor.ex:15: Phoenix.Endpoint.Server.init/1
(stdlib) supervisor.erl:294: :supervisor.init/1
(stdlib) gen_server.erl:328: :gen_server.init_it/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
{"Kernel pid terminated",application_controller,"{application_start_failure,tracker,{{shutdown,{failed_to_start_child,'Elixir.Tracker.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoint.Server',{#{'__exception__' => true,'__struct__' => 'Elixir.RuntimeError',message => <<\"server can't start because :port in config is nil, please use a valid port number\">>},[{'Elixir.Phoenix.Endpoint.Server',to_port,1,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,31}]},{'Elixir.Phoenix.Endpoint.Server',default,3,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,28}]},{'Elixir.Phoenix.Endpoint.Server','-init/1-fun-0-',5,[{file,\"lib/supervisor.ex\"},{line,17}]},{'Elixir.Enum','-reduce/3-lists^foldl/2-0-',3,[{file,\"lib/enum.ex\"},{line,1755}]},{'Elixir.Phoenix.Endpoint.Server',init,1,[{file,\"lib/supervisor.ex\"},{line,15}]},{supervisor,init,1,[{file,\"supervisor.erl\"},{line,294}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}}}},{'Elixir.Tracker',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tracker,{{shutdown,{failed_to_start_child,'Elixir.Tracker.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoint
Crash dump is being written to: erl_crash.dump...done
$ service tracker start
/etc/nginx/sites-available/tracker found
I repeated a few iterations of bump version -> push code to try to trigger an upgrade. Each had the same errors as before. Inspecting the build tree to see what the releases look like shows that the .tar.gz file is never created in the numbered release directory. Also in browser I can confirm that none of the tweaks I made in 0.1.3 through 0.1.6 are live, it's still running 0.1.2 on the server.
deploy@my-app:~/tracker$ tree -L 2 _build/prod/rel/tracker/releases/
_build/prod/rel/tracker/releases/
├── 0.1.3
│ ├── commands
│ ├── hooks
│ ├── start_clean.boot
│ ├── sys.config
│ ├── tracker.boot
│ ├── tracker.rel
│ ├── tracker.script
│ ├── tracker.sh
│ ├── tracker.tar.gz
│ └── vm.args
├── 0.1.4
│ ├── start_clean.boot
│ ├── sys.config
│ ├── tracker.boot
│ ├── tracker.rel
│ ├── tracker.script
│ ├── tracker.sh
│ └── vm.args
├── 0.1.5
│ ├── start_clean.boot
│ ├── sys.config
│ ├── tracker.boot
│ ├── tracker.rel
│ ├── tracker.script
│ ├── tracker.sh
│ └── vm.args
├── 0.1.6
│ ├── start_clean.boot
│ ├── sys.config
│ ├── tracker.boot
│ ├── tracker.rel
│ ├── tracker.script
│ ├── tracker.sh
│ └── vm.args
├── RELEASES
└── start_erl.data
6 directories, 31 files
I believe the issue described in #40 is the root cause of this, so closing this one for now.
I'm currently having this issue too. I just pulled down gatling yesterday. The init.d and the nginx files have the same number but the application endpoint says that :port is nil. It looks like the PORT environment isn't being passed into the application startup.
This fails on the ecto.setup task. I can pass in an arbitrary port number and get past it.
@adkron Yes, it's fixed with 255d0d691bf8c6e28b28c1d600e63c95d5153893 but there is no release with that fix yet.
I have my endpoint config set up as described in the README. When I attempt a deploy, I get an error that the port is nil:
Since the only thing the docs say about the port setting is "Gatling will set this for you automatically" I'm not sure what to look at next. Thanks or any help.
Environment: DigitalOcean server Ubuntu 16.04, nothing else on it but elixir, nginx, and postgresql. I followed the instructions in this blog post as closely as possible.