Reputation: 177
I have tried using the following startup commands, and both successfully start the app as reported in the _default_docker.log but the app service is stopping the container because a HTTP ping for port 8080 doesn't get a response.
pm2 start ecosystem.config.js
pm2 start npm -- run serve:ssr 4000
ecosystem.config.js file - works fine locally and launching the web app successfully on port 8080, and I have uploaded the file to ./site/wwwroot/ folder in the app service.
module.exports = {
apps : [{
name: 'ssrapp',
script: './dist/server/',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '2G'
}]
};
*_default_docker.log
2019-10-21T12:16:42.286884691Z _____
2019-10-21T12:16:42.287028489Z / _ \ __________ _________ ____
2019-10-21T12:16:42.287036989Z / /_\ \___ / | \_ __ \_/ __ \
2019-10-21T12:16:42.287041089Z / | \/ /| | /| | \/\ ___/
2019-10-21T12:16:42.287044689Z \____|__ /_____ \____/ |__| \___ >
2019-10-21T12:16:42.287048489Z \/ \/ \/
2019-10-21T12:16:42.287052189Z A P P S E R V I C E O N L I N U X
2019-10-21T12:16:42.287055789Z
2019-10-21T12:16:42.287059089Z Documentation: http://aka.ms/webapp-linux
2019-10-21T12:16:42.287062489Z NodeJS quickstart: https://aka.ms/node-qs
2019-10-21T12:16:42.287066089Z NodeJS Version : v10.16.3
2019-10-21T12:16:42.287069389Z
2019-10-21T12:16:42.318934970Z /opt/startup/init_container.sh: line 32: [: ==: unary operator expected
2019-10-21T12:16:42.325006910Z Oryx Version : 0.2.20191004.5, Commit: 95ca7f51b147da7b085922507f46106c664ae2a3
2019-10-21T12:16:42.325022210Z
2019-10-21T12:16:42.325252207Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2019-10-21T12:16:42.325267707Z Could not find operation ID in manifest. Generating an operation id...
2019-10-21T12:16:42.325272707Z Build Operation ID: a7a4fff6-536c-41b1-a328-b01a6913948f
2019-10-21T12:16:43.023896728Z Writing output script to '/opt/startup/startup.sh'
2019-10-21T12:16:43.026999997Z Running #!/bin/sh
2019-10-21T12:16:43.027017997Z
2019-10-21T12:16:43.027023796Z # Enter the source directory to make sure the script runs where the user expects
2019-10-21T12:16:43.027028696Z cd "/home/site/wwwroot"
2019-10-21T12:16:43.027033196Z
2019-10-21T12:16:43.027037496Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2019-10-21T12:16:43.027041996Z if [ -z "$PORT" ]; then
2019-10-21T12:16:43.027046596Z export PORT=8080
2019-10-21T12:16:43.027051196Z fi
2019-10-21T12:16:43.027055496Z
2019-10-21T12:16:43.027059696Z PATH="$PATH:/home/site/wwwroot" pm2 start npm -- run serve:ssr 8080
2019-10-21T12:16:43.988819791Z
2019-10-21T12:16:43.988873290Z -------------
2019-10-21T12:16:43.988899590Z
2019-10-21T12:16:43.988903390Z __/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
2019-10-21T12:16:43.988925889Z _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
2019-10-21T12:16:43.988931389Z _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
2019-10-21T12:16:43.988936189Z _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
2019-10-21T12:16:43.988949489Z _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
2019-10-21T12:16:43.988954289Z _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
2019-10-21T12:16:43.988976389Z _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
2019-10-21T12:16:43.988980789Z _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
2019-10-21T12:16:43.988985089Z _\///______________\///______________\///__\///////////////__
2019-10-21T12:16:43.988989589Z
2019-10-21T12:16:43.988993489Z
2019-10-21T12:16:43.989001189Z Runtime Edition
2019-10-21T12:16:43.989005689Z
2019-10-21T12:16:43.989009989Z PM2 is a Production Process Manager for Node.js applications
2019-10-21T12:16:43.989033588Z with a built-in Load Balancer.
2019-10-21T12:16:43.989037688Z
2019-10-21T12:16:43.989062588Z Start and Daemonize any application:
2019-10-21T12:16:43.989066588Z $ pm2 start app.js
2019-10-21T12:16:43.989070588Z
2019-10-21T12:16:43.989074388Z Load Balance 4 instances of api.js:
2019-10-21T12:16:43.989078288Z $ pm2 start api.js -i 4
2019-10-21T12:16:43.989082188Z
2019-10-21T12:16:43.989085988Z Monitor in production:
2019-10-21T12:16:43.989089888Z $ pm2 monitor
2019-10-21T12:16:43.989093788Z
2019-10-21T12:16:43.989097588Z Make pm2 auto-boot at server restart:
2019-10-21T12:16:43.989101488Z $ pm2 startup
2019-10-21T12:16:43.989105388Z
2019-10-21T12:16:43.989109388Z To go further checkout:
2019-10-21T12:16:43.989113288Z http://pm2.io/
2019-10-21T12:16:43.989117188Z
2019-10-21T12:16:43.989120988Z
2019-10-21T12:16:43.989124787Z -------------
2019-10-21T12:16:43.989128687Z
2019-10-21T12:16:44.101458966Z [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
2019-10-21T12:16:44.680135188Z [PM2] PM2 Successfully daemonized
2019-10-21T12:16:44.725026740Z [PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
2019-10-21T12:16:44.741207478Z [PM2] Done.
2019-10-21T12:16:44.762611464Z ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
2019-10-21T12:16:44.762636964Z │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
2019-10-21T12:16:44.762650664Z ├──────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
2019-10-21T12:16:44.762656664Z │ npm │ 0 │ N/A │ fork │ 82 │ online │ 0 │ 0s │ 0% │ 23.4 MB │ root │ disabled │
2019-10-21T12:16:44.762661564Z └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
2019-10-21T12:16:44.763132159Z Use `pm2 show <id|name>` to get more details about an app
*_docker.log
2019-10-21 12:16:42.471 INFO - Starting container for site
2019-10-21 12:16:42.471 INFO - docker run -d -p 44692:8081 --name mgssrtest__5706_0_5312eaa2_middleware -e WEBSITE_NODE_DEFAULT_VERSION=6.9.1 -e APPSETTING_WEBSITE_NODE_DEFAULT_VERSION=6.9.1 -e WEBSITE_CORS_ALLOWED_ORIGINS=https://uatservices.micksgarage.com,https://devtestservices.micksgarage.com,https://liveservices.micksgarage.com,https://www.micksgarage.com,https://mgssrlive.micksgarage.com,https://mgssrtest.micksgarage.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e PORT=8080 -e WEBSITES_PORT=8080 -e WEBSITE_SITE_NAME=mgssrtest -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=mgssrtest-live.azurewebsites.net -e WEBSITE_INSTANCE_ID=3952e083f9a0d4ead164e4cdd951561b6d2f3f64a50759e4377a1dd32b4aa296 -e HTTP_LOGGING_ENABLED=1 appsvc/middleware:1907112318 /Host.ListenUrl=http://0.0.0.0:8081 /Host.DestinationHostUrl=http://172.16.6.2:8080 /Host.UseFileLogging=true
2019-10-21 12:16:43.116 INFO - Initiating warmup request to container mgssrtest__5706_0_5312eaa2 for site mgssrtest__5706
2019-10-21 12:16:45.135 ERROR - Container mgssrtest__5706_0_5312eaa2 for site mgssrtest__5706 has exited, failing site start
2019-10-21 12:16:45.135 INFO - Initiating warmup request to container mgssrtest__5706_0_5312eaa2_middleware for site mgssrtest__5706
2019-10-21 12:16:48.471 INFO - Container mgssrtest__5706_0_5312eaa2_middleware for site mgssrtest__5706 initialized successfully and is ready to serve requests.
2019-10-21 12:16:48.478 ERROR - Container mgssrtest__5706_0_5312eaa2 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
I have tried setting the following settings in the App Service Application Settings (documentation on these is hard to come by and contradicting) but they don't seem to make any difference:
PORT: 8080
WEBSITES_PORT: 8080
CONTAINER_AVAILABILITY_CHECK_MODE: ReportOnly
WEBSITES_CONTAINER_START_TIME_LIMIT: 1800
Note: the node app launches fine in App Service with the start-up command "npm run serve:ssr", but I want to launch it via pm2 to avail of the monitoring and restart features.
It looks like the App Service environment is stopping the container because it doesn't respond to the HTTP ping in under 5 seconds, but I can't find any way to disable this to confirm that is the actual issue.
Upvotes: 3
Views: 5559
Reputation: 1075
I was having the same issue but finally found the answer. The problem on my side was that I was building the image using my MacBook M2 Max which runs on different architecture. Try to specify the architecture as the below command. Changing the build command to something like this
docker build --platform=linux/amd64 -t next-portfolio:latest .
has solved the issue. I was trying to deploy to Azure using AppService with Docker using Docker hub. After this all the port issue has disappeared.
Upvotes: 0
Reputation: 177
Architect Jamie suggestion in the comment below solved the issue, the --no-daemon parameter was needed. Thank you!
Upvotes: 4
Reputation: 2589
Your docker run
command is not exposing port 8080. You only have container port 44692 exposed as port 8081. You can see this in the logs as -p 44692:8081
.
Try adding this to the docker run command line:
-p 8080:8080
If that doesn't work, try -p 8080:8081
, or even just -p 8080
.
Upvotes: 2