【Azure 应用服务】更新镜像后并重启应用服务,部署日志始终没有出现加载新镜像成功的日志

简介: 【Azure 应用服务】更新镜像后并重启应用服务,部署日志始终没有出现加载新镜像成功的日志

问题描述

在App Service中部署镜像文件,发现镜像一直没有部署,重启App Service服务也无效果。

DockerFile如下:

FROM crunchgeek/php-fpm:7.0
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# apt 安装supervisor nginx python-pip
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list \
    && apt-get clean && apt-get update
RUN apt-get install -y openssh-server supervisor nginx python-pip imagemagick
RUN pip install -i https://mirrors.aliyun.com/pypi/simple XlsxWriter
# 开启ssh
RUN echo "root:Docker!" | chpasswd
COPY conf/ssh/sshd_config /etc/ssh/
RUN mkdir -p /tmp
COPY conf/ssh/ssh_setup.sh /tmp
RUN chmod +x /tmp/ssh_setup.sh \
    && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)
# 配置supervisor
RUN mkdir -p /var/log/supervisor
COPY conf/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
# 配置nginx
RUN mkdir -p /var/log/nginx
COPY conf/nginx/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx/phpdemotest.conf /etc/nginx/conf.d/phpdemotest.conf
# 配置php
RUN mkdir -p /var/log/php
COPY conf/php/php.ini /usr/local/etc/php/php.ini
COPY conf/php/www.conf /usr/local/etc/php-fpm.d/www.conf
# 暴露端口
EXPOSE 80
EXPOSE 2222
# 处理项目文件
WORKDIR /
COPY app /app
RUN mkdir -p /app/phpdemotest/cache && mkdir -p /app/phpdemotest/uploads
RUN chmod -R 777 /app
 
# 启动脚本
COPY run.sh /run.sh
RUN chmod +x /run.sh
ENTRYPOINT ["/run.sh"]

在App Service的 Default Docker 日志文件中发现错误:

2022-02-06T23:59:17.443332417Z + /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
2022-02-06T23:59:17.443373922Z + /usr/sbin/sshd
2022-02-06T23:59:18.452607133Z 2022-02-07 07:59:18,452 CRIT Supervisor running as root (no user in config file)
2022-02-06T23:59:18.456877344Z 2022-02-07 07:59:18,456 INFO supervisord started with pid 8
2022-02-06T23:59:19.465631733Z 2022-02-07 07:59:19,463 INFO spawned: 'nginx' with pid 12
2022-02-06T23:59:19.466909186Z 2022-02-07 07:59:19,466 INFO spawned: 'php-fpm' with pid 13
2022-02-06T23:59:19.494100139Z 2022-02-07 07:59:19,493 INFO exited: nginx (exit status 1; not expected)
2022-02-06T23:59:20.857528223Z 2022-02-07 07:59:20,853 INFO spawned: 'nginx' with pid 31
2022-02-06T23:59:20.857568522Z 2022-02-07 07:59:20,854 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-06T23:59:20.870432633Z 2022-02-07 07:59:20,870 INFO exited: nginx (exit status 1; not expected)
2022-02-06T23:59:22.879193415Z 2022-02-07 07:59:22,878 INFO spawned: 'nginx' with pid 32
2022-02-06T23:59:22.893106810Z 2022-02-07 07:59:22,892 INFO exited: nginx (exit status 1; not expected)
2022-02-06T23:59:25.913145415Z 2022-02-07 07:59:25,907 INFO spawned: 'nginx' with pid 33
2022-02-06T23:59:25.922158533Z 2022-02-07 07:59:25,921 INFO exited: nginx (exit status 1; not expected)
2022-02-06T23:59:26.927725113Z 2022-02-07 07:59:26,927 INFO gave up: nginx entered FATAL state, too many start retries too quickly
2022-02-07T00:09:25.488220881Z + /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
2022-02-07T00:09:25.488718279Z + /usr/sbin/sshd
2022-02-07T00:09:26.467977299Z 2022-02-07 08:09:26,467 CRIT Supervisor running as root (no user in config file)
2022-02-07T00:09:26.471996285Z 2022-02-07 08:09:26,471 INFO supervisord started with pid 8
2022-02-07T00:09:27.477601588Z 2022-02-07 08:09:27,475 INFO spawned: 'nginx' with pid 12
2022-02-07T00:09:27.479159791Z 2022-02-07 08:09:27,478 INFO spawned: 'php-fpm' with pid 13
2022-02-07T00:09:27.504344436Z 2022-02-07 08:09:27,504 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:09:28.696030787Z 2022-02-07 08:09:28,695 INFO spawned: 'nginx' with pid 31
2022-02-07T00:09:28.696917389Z 2022-02-07 08:09:28,696 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-07T00:09:28.709830112Z 2022-02-07 08:09:28,709 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:09:30.721563220Z 2022-02-07 08:09:30,718 INFO spawned: 'nginx' with pid 32
2022-02-07T00:09:30.733000942Z 2022-02-07 08:09:30,732 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:09:33.753600087Z 2022-02-07 08:09:33,750 INFO spawned: 'nginx' with pid 33
2022-02-07T00:09:33.770204819Z 2022-02-07 08:09:33,769 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:09:33.771144421Z 2022-02-07 08:09:33,770 INFO gave up: nginx entered FATAL state, too many start retries too quickly
2022-02-07T00:18:34.847730464Z + /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
2022-02-07T00:18:34.852556800Z + /usr/sbin/sshd
2022-02-07T00:18:35.682198497Z 2022-02-07 08:18:35,681 CRIT Supervisor running as root (no user in config file)
2022-02-07T00:18:35.685920425Z 2022-02-07 08:18:35,685 INFO supervisord started with pid 8
2022-02-07T00:18:36.693576944Z 2022-02-07 08:18:36,691 INFO spawned: 'nginx' with pid 12
2022-02-07T00:18:36.695261854Z 2022-02-07 08:18:36,694 INFO spawned: 'php-fpm' with pid 13
2022-02-07T00:18:36.720480795Z 2022-02-07 08:18:36,720 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:18:37.903152006Z 2022-02-07 08:18:37,898 INFO spawned: 'nginx' with pid 31
2022-02-07T00:18:37.905742221Z 2022-02-07 08:18:37,903 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-07T00:18:37.920186002Z 2022-02-07 08:18:37,919 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:18:39.933674870Z 2022-02-07 08:18:39,930 INFO spawned: 'nginx' with pid 32
2022-02-07T00:18:39.942568331Z 2022-02-07 08:18:39,942 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:18:42.961585686Z 2022-02-07 08:18:42,955 INFO spawned: 'nginx' with pid 33
2022-02-07T00:18:42.973046638Z 2022-02-07 08:18:42,972 INFO exited: nginx (exit status 1; not expected)
2022-02-07T00:18:42.974184633Z 2022-02-07 08:18:42,973 INFO gave up: nginx entered FATAL state, too many start retries too quickly

 

问题解答

从错误消息中发现,是 Nginx启动时候遇见错误 “ nginx entered FATAL state, too many start retries too quickly”。 最后发现是Nginx.config配置文件中格式错误,在修改后发布镜像后,App Service确没有拉取新的镜像,所以没有新镜像的部署日志。

这是因为App Service没有开启持续部署,当开启持续部署后,App Service会主动拉取最新的更新并自动完成部署。

 

PS: 当遇见镜像无法启动时,先在本地环境中验证镜像是否能成功启动,然后查看App Service的日志,从日志中定位具体问题。

 

参考资料

持续部署到 Azure 应用服务:https://docs.azure.cn/zh-cn/app-service/deploy-continuous-deployment?tabs=local

 

相关实践学习
通过日志服务实现云资源OSS的安全审计
本实验介绍如何通过日志服务实现云资源OSS的安全审计。
相关文章
|
Java Shell
「sh脚步模版自取」测试线排查的三个脚本:启动、停止、重启、日志保存
「sh脚步模版自取」测试线排查的三个脚本:启动、停止、重启、日志保存
256 1
|
12月前
|
JSON API 数据格式
【Azure APIM】如何把APIM中处理的请求的所有请求头保存在日志中?
Azure API Management 默认诊断日志不记录请求的 Header 和 Body 信息。为实现记录,可通过配置 Trace 策略解决。例如,使用 `context.Request.Headers` 和 `context.Request.Body` 获取相关信息,并以 JSON 或字符串格式保存。示例代码展示了如何将 Headers 转换为 JSON 或逗号分隔字符串形式记录。相关参考资料包括 Set Body Policy 和 Trace Policy 官方文档,帮助进一步了解与扩展功能。
278 36
|
12月前
|
存储 Windows
【Azure Cloud Service】微软云服务上的日志收集方法
本文介绍了在使用微软云服务(Cloud Service Extended Support)时,如何收集日志以分析未记录在应用日志中的服务异常。由于云服务基于传统虚拟机模式,需通过远程桌面登录实例,查看IIS、Windows Event及云服务组件日志(如WindowsAzureGuestAgent)。此外,可使用CollectGuestLogs.exe工具打包日志,或通过“File Server Resource Manager”检查日志存储配额是否不足。附参考文档链接供深入学习。
372 29
|
12月前
|
存储 监控 API
【Azure App Service】分享使用Python Code获取App Service的服务器日志记录管理配置信息
本文介绍了如何通过Python代码获取App Service中“Web服务器日志记录”的配置状态。借助`azure-mgmt-web` SDK,可通过初始化`WebSiteManagementClient`对象、调用`get_configuration`方法来查看`http_logging_enabled`的值,从而判断日志记录是否启用及存储方式(关闭、存储或文件系统)。示例代码详细展示了实现步骤,并附有执行结果与官方文档参考链接,帮助开发者快速定位和解决问题。
325 22
|
API 开发工具 Python
【Azure Policy】分享Policy实现对Azure Activity Log导出到Log A workspace中
在Policy Rule部分中,选择资源的类型为 "Microsoft.Resources/subscriptions", 效果使用 DeployIfNotExists (如果不存在,则通过修复任务进行修正。 在 existenceCondition 条件中,如果当前订阅已经启用了 diagnostic setting并且输出日志到同一个Log A workspace,表示满足Policy要求,不需要进行修正。 在 deployment 中,使用了 ARM 模板, 为订阅添加Diagnostic Setting并且所有的日志Category均启用。
149 3
|
Kubernetes 数据安全/隐私保护 容器
【Azure APIM】APIM Self-Hosted网关中,添加网关日志以记录请求头信息(Request Header / Response Header)
【Azure APIM】APIM Self-Hosted网关中,添加网关日志以记录请求头信息(Request Header / Response Header)
248 3
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
147 3
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
192 1
|
消息中间件 Kubernetes Kafka
微服务从代码到k8s部署应有尽有系列(十一、日志收集)
微服务从代码到k8s部署应有尽有系列(十一、日志收集)