首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure python App在启动时崩溃,"/opt/ startup /startup.sh: 32: /opt/startup/startup.sh:语法错误:"(“意外”)

Azure python App在启动时崩溃,"/opt/ startup /startup.sh: 32: /opt/startup/startup.sh:语法错误:"(“意外”)
EN

Stack Overflow用户
提问于 2022-09-20 02:00:48
回答 1查看 69关注 0票数 0

我的Azure应用服务已经运行两年多了,没有问题。出于某种原因,App今天已经开始抛出此错误(如日志流中所示)。

代码语言:javascript
复制
2022-09-20T01:48:30.239101040Z   _____
2022-09-20T01:48:30.239108140Z   /  _  \ __________ _________   ____
2022-09-20T01:48:30.239112540Z  /  /_\  \___   /  |  \_  __ \_/ __ \
2022-09-20T01:48:30.239116940Z /    |    \/    /|  |  /|  | \/\  ___/
2022-09-20T01:48:30.239121040Z \____|__  /_____ \____/ |__|    \___  >
2022-09-20T01:48:30.239125640Z         \/      \/                  \/
2022-09-20T01:48:30.239129840Z
2022-09-20T01:48:30.239133540Z A P P   S E R V I C E   O N   L I N U X
2022-09-20T01:48:30.239137540Z
2022-09-20T01:48:30.239141340Z Documentation: http://aka.ms/webapp-linux
2022-09-20T01:48:30.239145340Z Python 3.9.7
2022-09-20T01:48:30.239149240Z Note: Any data outside '/home' is not persisted
2022-09-20T01:48:30.424663485Z Starting OpenBSD Secure Shell server: sshd.
2022-09-20T01:48:30.468606343Z Site's appCommandLine: gunicorn --bind 0.0.0.0 --workers 1 --timeout 1200 application:create_app()
2022-09-20T01:48:30.858384059Z Starting periodic command scheduler: cron.
2022-09-20T01:48:30.858422059Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'gunicorn --bind 0.0.0.0 --workers 1 --timeout 1200 application:create_app()'
2022-09-20T01:48:30.858428859Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2022-09-20T01:48:30.858433359Z Build Operation ID: |BPDiFi+oukQ=.99194caa_
2022-09-20T01:48:30.858437559Z Oryx Version: 0.2.20220812.1, Commit: cdf6b1bef165d05b94830e963646495967d938f4, ReleaseTagName: 20220812.1
2022-09-20T01:48:31.348409808Z Writing output script to '/opt/startup/startup.sh'
2022-09-20T01:48:31.423025506Z Found virtual environment .tar.gz archive.
2022-09-20T01:48:31.426681211Z Removing existing virtual environment directory /antenv...
2022-09-20T01:48:31.495728503Z Extracting to directory /antenv...
2022-09-20T01:48:52.688655050Z Using packages from virtual environment antenv located at /antenv.
2022-09-20T01:48:52.689532751Z Updated PYTHONPATH to ':/opt/startup/app_logs:/opt/startup/code_profiler:/antenv/lib/python3.9/site-packages'
2022-09-20T01:48:52.692766855Z /opt/startup/startup.sh: 32: /opt/startup/startup.sh: Syntax error: "(" unexpected
2022-09-20T01:49:03.031Z ERROR - Container customapi__b4ba_0_b6eb860f for site customapi__b4ba has exited, failing site start
2022-09-20T01:49:03.033Z INFO  - Initiating warmup request to container customapi__b4ba_0_b6eb860f_middleware for site customapi__b4ba
2022-09-20T01:49:06.318Z INFO  - Container customapi__b4ba_0_b6eb860f_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T01:49:06.386Z ERROR - Container customapi__b4ba_0_b6eb860f didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T01:49:06.419Z INFO  - Stopping site customapi__b4ba because it failed during startup.

我已经尝试更新App以使用Python3.9运行(它以前运行在Python3.7上),但问题仍然存在。

有人知道为什么startup.sh脚本在使用了几年后现在会抛出错误吗?为什么现在会发生这种事,我该怎么解决呢?

以下是一些容器日志:

代码语言:javascript
复制
2022-09-20T01:48:24.614Z INFO  -  Status: Downloaded newer image for 10.0.4.254:13209/appsvc/python:3.9_20220818.1.tuxprod
2022-09-20T01:48:24.618Z INFO  - Pull Image successful, Time taken: 1 Minutes and 30 Seconds
2022-09-20T01:48:24.680Z INFO  - Starting container for site
2022-09-20T01:48:24.681Z INFO  - docker run -d -p 6740:8000 --name customapi__b4ba_0_b6eb860f -e WEBSITE_CORS_ALLOWED_ORIGINS=* -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITE_SITE_NAME=customapi -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=customapi.azurewebsites.net -e WEBSITE_INSTANCE_ID=8e6219532b7937949116433adec046a116d12b4988fa8c712cf7d129bf896139 -e HTTP_LOGGING_ENABLED=1 -e WEBSITE_USE_DIAGNOSTIC_SERVER=True appsvc/python:3.9_20220818.1.tuxprod gunicorn --bind 0.0.0.0 --workers 1 --timeout 1200 application:create_app() 

2022-09-20T01:48:34.696Z INFO  - Initiating warmup request to container customapi__b4ba_0_b6eb860f for site customapi__b4ba
2022-09-20T01:48:50.130Z INFO  - Waiting for response to warmup request for container customapi__b4ba_0_b6eb860f. Elapsed time = 15.433705 sec
2022-09-20T01:49:03.031Z ERROR - Container customapi__b4ba_0_b6eb860f for site customapi__b4ba has exited, failing site start
2022-09-20T01:49:03.033Z INFO  - Initiating warmup request to container customapi__b4ba_0_b6eb860f_middleware for site customapi__b4ba
2022-09-20T01:49:06.318Z INFO  - Container customapi__b4ba_0_b6eb860f_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T01:49:06.386Z ERROR - Container customapi__b4ba_0_b6eb860f didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T01:49:06.419Z INFO  - Stopping site customapi__b4ba because it failed during startup.
2022-09-20T01:56:56.412Z INFO  - Pulling image: mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T01:56:57.332Z INFO  - stage5 Pulling from appsvc/middleware
2022-09-20T01:56:57.363Z INFO  -  Digest: sha256:f2a0c60712a928834c3dcc13c3f76f99bec497001417c303fed69c0a2a1bdac1
2022-09-20T01:56:57.371Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T01:56:57.395Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-09-20T01:56:57.424Z INFO  - Starting container for site
2022-09-20T01:56:57.425Z INFO  - docker run -d -p 7482:8181 -p 4775:8082 --name customapi__b4ba_0_a2022-09-20T01:57:00.921Z INFO  - Initiating warmup request to container customapi__b4ba_0_ad8d94a3 for site customapi__b4ba
2022-09-20T01:57:30.615Z ERROR - Container customapi__b4ba_0_ad8d94a3 for site customapi__b4ba has exited, failing site start
2022-09-20T01:57:30.617Z INFO  - Initiating warmup request to container customapi__b4ba_0_ad8d94a3_middleware for site customapi__b4ba
2022-09-20T01:57:34.296Z INFO  - Container customapi__b4ba_0_ad8d94a3_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T01:57:34.326Z ERROR - Container customapi__b4ba_0_ad8d94a3 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T01:57:34.344Z INFO  - Stopping site customapi__b4ba because it failed during startup.
2022-09-20T02:01:56.102Z INFO  - Pulling image: mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:01:57.514Z INFO  - stage5 Pulling from appsvc/middleware
2022-09-20T02:01:57.515Z INFO  -  Digest: sha256:f2a0c60712a928834c3dcc13c3f76f99bec497001417c303fed69c0a2a1bdac1
2022-09-20T02:01:57.517Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:01:57.520Z INFO  - Pull Image successful, Time taken: 0 Minutes and 1 Seconds
2022-09-20T02:01:57.558Z INFO  - Starting container for site
2022-09-20T02:01:57.561Z INFO  - docker run -d -p 6519:8181 -p 6613:8082 --name customapi__b4ba_0_92022-09-20T02:02:03.307Z INFO  - Initiating warmup request to container customapi__b4ba_0_90c34e20 for site customapi__b4ba
2022-09-20T02:02:18.758Z INFO  - Waiting for response to warmup request for container customapi__b4ba_0_90c34e20. Elapsed time = 15.4515753 sec
2022-09-20T02:02:24.130Z ERROR - Container customapi__b4ba_0_90c34e20 for site customapi__b4ba has exited, failing site start
2022-09-20T02:02:24.132Z INFO  - Initiating warmup request to container customapi__b4ba_0_90c34e20_middleware for site customapi__b4ba
2022-09-20T02:02:27.422Z INFO  - Container customapi__b4ba_0_90c34e20_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T02:02:27.457Z ERROR - Container customapi__b4ba_0_90c34e20 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T02:02:27.465Z INFO  - Stopping site customapi__b4ba because it failed during startup.
2022-09-20T02:07:02.458Z INFO  - Pulling image: mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:07:03.170Z INFO  - stage5 Pulling from appsvc/middleware
2022-09-20T02:07:03.174Z INFO  -  Digest: sha256:f2a0c60712a928834c3dcc13c3f76f99bec497001417c303fed69c0a2a1bdac1
2022-09-20T02:07:03.177Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:07:03.180Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-09-20T02:07:03.204Z INFO  - Starting container for site
2022-09-20T02:07:03.206Z INFO  - docker run -d -p 3406:8181 -p 7111:8082 --name customapi__b4ba_0_92022-09-20T02:07:06.557Z INFO  - Initiating warmup request to container customapi__b4ba_0_9517e44c for site customapi__b4ba
2022-09-20T02:07:24.676Z INFO  - Waiting for response to warmup request for container customapi__b4ba_0_9517e44c. Elapsed time = 18.1187192 sec
2022-09-20T02:07:35.382Z ERROR - Container customapi__b4ba_0_9517e44c for site customapi__b4ba has exited, failing site start
2022-09-20T02:07:35.384Z INFO  - Initiating warmup request to container customapi__b4ba_0_9517e44c_middleware for site customapi__b4ba
2022-09-20T02:07:38.627Z INFO  - Container customapi__b4ba_0_9517e44c_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T02:07:38.655Z ERROR - Container customapi__b4ba_0_9517e44c didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T02:07:38.669Z INFO  - Stopping site customapi__b4ba because it failed during startup.
2022-09-20T02:12:05.944Z INFO  - Pulling image: mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:12:06.754Z INFO  - stage5 Pulling from appsvc/middleware
2022-09-20T02:12:06.757Z INFO  -  Digest: sha256:f2a0c60712a928834c3dcc13c3f76f99bec497001417c303fed69c0a2a1bdac1
2022-09-20T02:12:06.759Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:12:06.761Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-09-20T02:12:08.324Z INFO  - Starting container for site
2022-09-20T02:12:08.326Z INFO  - docker run -d -p 3576:8181 -p 9646:8082 --name customapi__b4ba_0_82022-09-20T02:12:25.519Z INFO  - Initiating warmup request to container customapi__b4ba_0_86876b9b for site customapi__b4ba
2022-09-20T02:12:25.578Z ERROR - Container customapi__b4ba_0_86876b9b for site customapi__b4ba has exited, failing site start
2022-09-20T02:12:25.579Z INFO  - Initiating warmup request to container customapi__b4ba_0_86876b9b_middleware for site customapi__b4ba
2022-09-20T02:12:27.807Z INFO  - Container customapi__b4ba_0_86876b9b_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T02:12:27.838Z ERROR - Container customapi__b4ba_0_86876b9b didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T02:12:27.854Z INFO  - Stopping site customapi__b4ba because it failed during startup.
2022-09-20T02:16:56.823Z INFO  - Pulling image: mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:16:57.610Z INFO  - stage5 Pulling from appsvc/middleware
2022-09-20T02:16:57.612Z INFO  -  Digest: sha256:f2a0c60712a928834c3dcc13c3f76f99bec497001417c303fed69c0a2a1bdac1
2022-09-20T02:16:57.618Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/middleware:stage5
2022-09-20T02:16:57.627Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-09-20T02:16:57.647Z INFO  - Starting container for site
2022-09-20T02:16:57.649Z INFO  - docker run -d -p 5202:8181 -p 1785:8082 --name customapi__b4ba_0_12022-09-20T02:17:01.008Z INFO  - Initiating warmup request to container customapi__b4ba_0_10213bb4 for site customapi__b4ba
2022-09-20T02:17:24.074Z INFO  - Waiting for response to warmup request for container customapi__b4ba_0_10213bb4. Elapsed time = 23.0655065 sec
2022-09-20T02:17:28.868Z ERROR - Container customapi__b4ba_0_10213bb4 for site customapi__b4ba has exited, failing site start
2022-09-20T02:17:28.870Z INFO  - Initiating warmup request to container customapi__b4ba_0_10213bb4_middleware for site customapi__b4ba
2022-09-20T02:17:32.265Z INFO  - Container customapi__b4ba_0_10213bb4_middleware for site customapi__b4ba initialized successfully and is ready to serve requests.
2022-09-20T02:17:32.305Z ERROR - Container customapi__b4ba_0_10213bb4 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2022-09-20T02:17:32.318Z INFO  - Stopping site customapi__b4ba because it failed during startup.
EN

回答 1

Stack Overflow用户

发布于 2022-09-20 11:07:30

如果容器无法启动或退出,则应用程序可能面临任何错误或异常。

为了缩小问题范围,您可以利用Azure Portal中的诊断工具并选择Application;Container;容器崩溃,这有助于调查容器无法启动的潜在原因,这可能会导致部署和可用性问题。

您可以检查部署日志和应用程序日志中的任何错误消息。这些日志通常会指出可能阻止应用程序部署或应用程序启动的特定问题。

查看有关故障排除指南的详细教程,

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73780897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档