Customize launch command of node.js app

I was trying to figure out how to customize the launch command of a Node.js app. It appears like it defaults to npm start. I would like to change it to node app.js or ./node_modules/.bin fastify, the main reason being that npm swallows signals sent to the process started in package.json run scripts (they never make it to the child process typically).

In heroku, a common solution was to just ship a Proc file with the command you wanted heroku to run instead of defaulting to npm run. Does that work in fly as well? Is there a better solution? Thanks.

Interesting insights for fastify usage.

Can you share your dockerfile and fly.toml?

Usually the way to go is to put it at your dockerfiles entry point so it should be easy to do and I can help you with that.

1 Like

Thanks, here is my fly.toml: breadcrum.net/fly.toml at master · hifiwi-fi/breadcrum.net · GitHub

I do not have a docker file.

Ideally there would be something as simple as release_command but for like a start command.

cmd and entrypoint look promising, but I’m not sure which one I would want in this case.

Since your app is using the Heroku nodejs buildpack, most of the Heroku documentation should apply. So, adding a Procfile should work.

2 Likes

Ok great, good to know. Now just waiting for a remote builder to free up:

d":false,"status":"pending","version":0,"appUrl":null,"platformVersion":null,"config":{"definition":{"kill_timeout":5,"kill_signal":"SIGINT","processes":[],"experimental":{"allowed_public_ports":[],"auto_rollback":true},"services":[{"processes":["app"],"protocol":"tcp","internal_port":8080,"concurrency":{"soft_limit":20,"hard_limit":25,"type":"connections"},"ports":[{"port":80,"handlers":["http"],"force_https":true},{"port":443,"handlers":["tls","http"]}],"tcp_checks":[{"interval":"15s","timeout":"2s","grace_period":"1s","restart_limit":0}],"http_checks":[],"script_checks":[]}],"env":{}}},"organization":{"id":"vwJ9K2ApYNJyqtROR9mkLn8mkJI6pm","slug":"hifiwifi"},"services":[{"description":"TCP 80/443 ⇢ 8080","protocol":"TCP","internalPort":8080,"ports":[{"port":80,"handlers":["HTTP"]},{"port":443,"handlers":["TLS","HTTP"]}]}],"ipAddresses":{"nodes":[]},"imageDetails":{"repository":"unknown","version":"unknown"},"machines":{"nodes":[]}}}}
Waiting for remote builder fly-builder-summer-paper-5691... ⣽ DEBUG --> POST https://api.fly.io/graphql {{"query":"mutation($input: ValidateWireGuardPeersInput!) { validateWireGuardPeers(input: $input) { invalidPeerIps } }","variables":{"input":{"peerIps":["fdaa:0:57de:a7b:177d:0:a:2","fdaa:0:4e05:a7b:177d:0:a:2","fdaa:0:5794:a7b:177d:0:a:2"]}}}
}
DEBUG <-- 200 https://api.fly.io/graphql (132.93ms) {"data":{"validateWireGuardPeers":{"invalidPeerIps":[]}}}
Waiting for remote builder fly-builder-summer-paper-5691... ⣻ DEBUG Remote builder available, but pinging again in 50ms to be sure
Waiting for remote builder fly-builder-summer-paper-5691... ⢿ DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
Waiting for remote builder fly-builder-summer-paper-5691... ⡿ DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
Waiting for remote builder fly-builder-summer-paper-5691... ⣟ DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
Waiting for remote builder fly-builder-summer-paper-5691... ⣯ DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
DEBUG Remote builder available, but pinging again in 50ms to be sure
Waiting for remote builder fly-builder-summer-paper-5691... ⣷ DEBUG Remote builder is ready to build!
Remote builder fly-builder-summer-paper-5691 ready

Can’t tell if its the crappy cafe wifi or somethings going wrong with fly, but just hung up here.

Can you try it again to see if the same thing happens?

Just getting stuck on this step:

flyctl deploy
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-red-field-808 ready
==> Building image with Buildpacks
--> docker host: 20.10.12 linux x86_64
Error failed to fetch an image or build from source: failed to fetch builder image 'index.docker.io/heroku/buildpacks:20': Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Which region are you in? You can check with: https://debug.fly.dev/

=== Headers ===
Host: debug.fly.dev
Accept-Encoding: gzip, deflate, br
Fly-Forwarded-Ssl: on
Fly-Forwarded-Port: 443
Fly-Region: sea
Via: 2 fly.io
Fly-Dispatch-Start: t=1648762750538600;instance=0e4a6cdd
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15
Fly-Client-Ip: 50.46.19.57
X-Forwarded-Proto: https
X-Forwarded-Ssl: on
Accept-Language: en-US,en;q=0.9
X-Forwarded-For: 50.46.19.57, 77.83.140.164
Fly-Forwarded-Proto: https
X-Forwarded-Port: 443
Fly-Request-Id: 01FZGYP1JA4GNF1AK28VJ5ADG4-sea
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: https://community.fly.io/
X-Request-Start: t=1648762750538138

=== ENV ===
FLY_ALLOC_ID=0e4a6cdd-9bbb-5fb9-a391-2cb7e449343f
FLY_APP_NAME=debug
FLY_PUBLIC_IP=2605:4c40:93:4df6:0:e4a:6cdd:1
FLY_REGION=sea
FLY_VM_MEMORY_MB=128
GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D
HOME=/root
LANG=C.UTF-8
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHON_GET_PIP_SHA256=01249aa3e58ffb3e1686b7141b4e9aac4d398ef4ac3012ed9dff8dd9f685ffe0
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/d781367b97acf0ece7e9e304bf281e99b618bf10/public/get-pip.py
PYTHON_PIP_VERSION=21.2.4
PYTHON_SETUPTOOLS_VERSION=57.5.0
PYTHON_VERSION=3.10.0
TERM=linux
WS=this
is
a
test
cgroup_enable=memory

2022-03-31 21:39:10.543169204 +0000 UTC m=+1825422.013265521
% flyctl doctor
Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... Nope
Pinging WireGuard gateway (give us a sec)... PASSED

Ok, it just started working.

Now failing at this step:

[Installing Node.js distribution]
Downloading Node.js 17.5.0

[Error: Node.js engine distribution error]
Couldn't download Node.js distribution: HTTP error while downloading file: https://s3.amazonaws.com/heroku-nodebin/node/release/linux-x64/node-v17.5.0-linux-x64.tar.gz: Connection Failed: Connect error: connection timed out
ERROR: failed to build: exit status 40
Error failed to fetch an image or build from source: executing lifecycle: failed with status code: 51

There’s a network issue between SEA and AWS, but we’re not sure if it’s on our end or not. We’re looking into it.

edit: Fly.io Status - Connectivity failures in the Seattle region

1 Like

Got it all sorted by trying LA. Seattle wasn’t having a good day.