Question

New "App" feature, how to serve nodejs application? I get Deploy Error: Non-Zero Exit Code

Posted November 9, 2021 44 views
DigitalOcean App Platform

Hey, just noticed the new DO App feature, which is amazing, exactly what I was looking for and just happened it was released today?!

But for some reason, after a successful build, fail to recognise that my service is running; I get the “Deploy Error: Non-Zero Exit Code”;

This might be related to the fact that I am running pm2 to keep the service alive. It’s not required?

Here’s how the run script looks like:

#!/bin/bash

npx pm2 start ./dist -- --port "$HTTP_PORT"

Here’s how the log looks like:

[2021-11-09 18:16:21] => Initializing build
[2021-11-09 18:16:21] => Retrieving source code to /workspace
[2021-11-09 18:16:21] => Selecting branch "main"
[2021-11-09 18:16:22] => Checking out commit "64495e8948988f076040beea8b7bdf067f32775c"
[2021-11-09 18:16:23] => Got source_dir: /
[2021-11-09 18:16:23] => Using workspace root /workspace
[2021-11-09 18:16:23] 
[2021-11-09 18:16:23] => Building app using buildpacks
[2021-11-09 18:16:23] => Injecting app environment variables:
[2021-11-09 18:16:23]      OPENWEATHER_API_KEY HTTP_PORT
[2021-11-09 18:16:23] => Configuring custom build command to be run at the end of the build:
[2021-11-09 18:16:23]      yarn build
[2021-11-09 18:16:23] => Running buildpack detection
[2021-11-09 18:16:23] 
[2021-11-09 18:16:24] heroku/nodejs-engine  0.5.0
[2021-11-09 18:16:24] digitalocean/node     0.3.4
[2021-11-09 18:16:24] digitalocean/procfile 0.0.3
[2021-11-09 18:16:24] digitalocean/custom   0.1.0
[2021-11-09 18:16:24] 
[2021-11-09 18:16:24] For documentation on the buildpacks used to build your app, please see:
[2021-11-09 18:16:24]    Node.js: https://do.co/apps-buildpack-node
[2021-11-09 18:16:24] 
[2021-11-09 18:16:24] => Building app
[2021-11-09 18:16:24] 
[2021-11-09 18:16:24] ---> Node.js Buildpack
[2021-11-09 18:16:24] ---> Installing toolbox
[2021-11-09 18:16:24] ---> - jq
[2021-11-09 18:16:25] ---> - yj
[2021-11-09 18:16:25] ---> Getting Node version
[2021-11-09 18:16:25] ---> Resolving Node version
[2021-11-09 18:16:27] ---> Downloading and extracting Node v12.22.7
[2021-11-09 18:16:40] ---> Parsing package.json
[2021-11-09 18:16:42] ---> Installing yarn@1.22.17
[2021-11-09 18:16:46] ---> No file to start server
[2021-11-09 18:16:46] ---> either use 'docker run' to start container or add index.js or server.js
[2021-11-09 18:16:46] Project contains yarn.lock, using yarn
[2021-11-09 18:16:46] Installing node_modules using yarn (from yarn.lock)
[2021-11-09 18:16:46] Running yarn install
[2021-11-09 18:16:46] 
[2021-11-09 18:16:47] yarn install v1.22.17
[2021-11-09 18:16:47] [1/4] Resolving packages...
[2021-11-09 18:16:47] [2/4] Fetching packages...
[2021-11-09 18:17:03] [3/4] Linking dependencies...
[2021-11-09 18:17:03] warning " > eslint-config-airbnb-base@15.0.0" has unmet peer dependency "eslint-plugin-import@^2.25.2".
[2021-11-09 18:17:03] warning "eslint-config-airbnb-typescript > eslint-config-airbnb-base@14.2.1" has incorrect peer dependency "eslint@^5.16.0 || ^6.8.0 || ^7.2.0".
[2021-11-09 18:17:03] warning "eslint-config-airbnb-typescript > eslint-config-airbnb-base@14.2.1" has unmet peer dependency "eslint-plugin-import@^2.22.1".
[2021-11-09 18:17:06] [4/4] Building fresh packages...
[2021-11-09 18:17:06] Done in 19.04s.
[2021-11-09 18:17:06] 
[2021-11-09 18:17:08] Running custom build command: yarn build
[2021-11-09 18:17:08] yarn run v1.22.17
[2021-11-09 18:17:08] $ tsc -b tsconfig.json
[2021-11-09 18:17:13] Done in 5.00s.
[2021-11-09 18:17:17] 
[2021-11-09 18:17:17] => Uploading the built Docker image to the container registry...
[2021-11-09 18:17:22] Adding layer 'heroku/nodejs-engine:nodejs'
[2021-11-09 18:17:24] Adding layer 'heroku/nodejs-engine:yarn'
[2021-11-09 18:17:31] Adding 2/2 app layer(s)
[2021-11-09 18:17:31] Adding layer 'launcher'
[2021-11-09 18:17:31] Adding layer 'config'
[2021-11-09 18:17:31] Adding label 'io.buildpacks.lifecycle.metadata'
[2021-11-09 18:17:31] Adding label 'io.buildpacks.build.metadata'
[2021-11-09 18:17:31] Adding label 'io.buildpacks.project.metadata'
[2021-11-09 18:19:00] *** Images (sha256:9c60b3772abb45409d3d702a1c8bdfe2557b71de345fd34f83ddcd7d895439b8):
[2021-11-09 18:19:00]       <image-1>
[2021-11-09 18:19:01] Layer cache not found
[2021-11-09 18:19:01] Adding cache layer 'heroku/nodejs-engine:nodejs'
[2021-11-09 18:19:03] Adding cache layer 'heroku/nodejs-engine:toolbox'
[2021-11-09 18:19:03] Adding cache layer 'heroku/nodejs-engine:yarn'
[2021-11-09 18:19:07] Adding cache layer 'digitalocean/node:node_modules'
[2021-11-09 18:19:30] => Uploaded the built image to the container registry
[2021-11-09 18:19:30] => Build complete

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey there!

PM2 isn’t required within App Platform. App Platform will automatically restart the container if the application dies. However you may want to try starting this application using PM2 runtime instead. Set something likenpx pm2-runtime start ./dist -- --port "$HTTP_PORT" You could set that in the run command field when creating your application rather then as a start script as well. You can also run this without PM2 if you would like.

Hope it helps!
Nate