我尝试使用以下启动命令,并且都成功启动了_default_docker.log中报告的应用程序,但是应用程序服务正在停止容器,因为端口8080的HTTP ping无法获得响应。
pm2 start ecosystem.config.js
pm2 start npm -- run serve:ssr 4000
ecosystem.config.js文件-在本地运行良好,并在端口8080上成功启动了Web应用程序,并且我已将该文件上传到应用程序服务中的./site/wwwroot/文件夹中。
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.
我尝试在App Service应用程序设置中设置以下设置(有关这些文档很难获得且相互矛盾),但它们似乎没有任何区别:
端口:8080
WEBSITES_PORT:8080
CONTAINER_AVAILABILITY_CHECK_MODE:仅报告
WEBSITES_CONTAINER_START_TIME_LIMIT:1800
注意:使用启动命令“ npm run serve:ssr”可以在App Service中正常启动节点应用程序,但是我想通过pm2来启动它,以利用监视和重新启动功能。
App Service环境似乎正在停止容器,因为它在5秒内没有响应HTTP ping,但是我找不到任何方法来禁用它以确认这是实际问题。
答案 0 :(得分:1)
您的-p 8080:8080
命令没有公开端口8080。您只有将容器端口44692公开为端口8081。您可以在日志中以-p 8080:8081
看到它。
尝试将其添加到docker run命令行:
-p 8080
如果这不起作用,请尝试{{1}}甚至尝试{{1}}。
答案 1 :(得分:0)
Architect Jamie建议解决了该问题,需要--no-daemon参数。谢谢!