从 Commits · discourse/discourse · GitHub 升级到最新版本导致网站宕机,以下是日志中值得注意的部分:
I, [2022-02-15T05:27:48.995821 #1] INFO -- : 在 /etc/postgresql/13/main/pg_hba.conf 中将 (?-mix:^host.*all.*all.*127.*$) 替换为 host all all 0.0.0.0/0 md5
I, [2022-02-15T05:27:48.997476 #1] INFO -- : 在 /etc/postgresql/13/main/pg_hba.conf 中将 (?-mix:^host.*all.*all.*::1\/128.*$) 替换为 host all all ::/0 md5
I, [2022-02-15T05:27:48.998553 #1] INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
I, [2022-02-15T05:27:49.003918 #1] INFO -- : > sleep 5
2022-02-15 05:27:49.151 UTC [41] LOG: 正在启动 PostgreSQL 13.5 (Debian 13.5-1.pgdg110+1),架构 x86_64-pc-linux-gnu,由 gcc (Debian 10.2.1-6) 10.2.1 20210110 编译,64 位
2022-02-15 05:27:49.152 UTC [41] LOG: 正在监听 IPv4 地址 "0.0.0.0",端口 5432
2022-02-15 05:27:49.152 UTC [41] LOG: 正在监听 IPv6 地址 "::",端口 5432
2022-02-15 05:27:49.162 UTC [41] LOG: 正在监听 Unix 套接字 "/var/run/postgresql/.s.PGSQL.5432"
2022-02-15 05:27:49.184 UTC [44] LOG: 数据库系统在 2022-02-15 00:12:32 UTC 已关闭
2022-02-15 05:27:49.209 UTC [41] LOG: 数据库系统已准备好接受连接
I, [2022-02-15T05:27:54.013563 #1] INFO -- :
I, [2022-02-15T05:27:54.015179 #1] INFO -- : > su postgres -c 'createdb discourse' || true
2022-02-15 05:27:54.259 UTC [54] postgres@postgres ERROR: 数据库 "discourse" 已存在
2022-02-15 05:27:54.259 UTC [54] postgres@postgres STATEMENT: CREATE DATABASE discourse;
createdb: error: 数据库创建失败:ERROR: 数据库 "discourse" 已存在
I, [2022-02-15T05:27:54.270626 #1] INFO -- :
I, [2022-02-15T05:27:54.272627 #1] INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2022-02-15 05:27:54.425 UTC [58] postgres@discourse ERROR: 角色 "discourse" 已存在
2022-02-15 05:27:54.425 UTC [58] postgres@discourse STATEMENT: create user discourse;
ERROR: 角色 "discourse" 已存在
I, [2022-02-15T05:27:54.431376 #1] INFO -- :
I, [2022-02-15T05:27:54.431915 #1] INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
I, [2022-02-15T05:27:54.533010 #1] INFO -- : GRANT
I, [2022-02-15T05:27:55.303411 #1] INFO -- : > echo redis installed
I, [2022-02-15T05:27:55.310858 #1] INFO -- : redis installed
I, [2022-02-15T05:27:55.312551 #1] INFO -- : > cat /etc/redis/redis.conf | grep logfile
I, [2022-02-15T05:27:55.323276 #1] INFO -- : logfile ""
I, [2022-02-15T05:27:55.324362 #1] INFO -- : > exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
I, [2022-02-15T05:27:55.329352 #1] INFO -- : > sleep 10
102:C 15 Feb 2022 05:27:55.343 # oO0OoO0OoO0Oo Redis 正在启动 oO0OoO0OoO0Oo
102:C 15 Feb 2022 05:27:55.343 # Redis 版本=6.2.6, 位宽=64, 提交=00000000, 修改=0, pid=102, 刚刚启动
102:C 15 Feb 2022 05:27:55.343 # 配置已加载
102:M 15 Feb 2022 05:27:55.346 * 单调时钟:POSIX clock_gettime
102:M 15 Feb 2022 05:27:55.349 * 运行模式=独立,端口=6379。
102:M 15 Feb 2022 05:27:55.350 # 警告:TCP backlog 设置 511 无法强制执行,因为 /proc/sys/net/core/somaxconn 被设置为较低的值 128。
102:M 15 Feb 2022 05:27:55.350 # 服务器已初始化
102:M 15 Feb 2022 05:27:55.350 # 警告:overcommit_memory 设置为 0!在低内存条件下后台保存可能会失败。要解决此问题,请将 'vm.overcommit_memory = 1' 添加到 /etc/sysctl.conf,然后重启或运行命令 'sysctl vm.overcommit_memory=1' 使其生效。
102:M 15 Feb 2022 05:27:55.352 * 正在加载由版本 6.2.6 生成的 RDB
102:M 15 Feb 2022 05:27:55.352 * RDB 年龄 18923 秒
102:M 15 Feb 2022 05:27:55.352 * 创建时 RDB 内存使用量 133.51 MB
102:M 15 Feb 2022 05:27:55.912 # RDB 加载完成,已加载键:7294,已过期键:127。
102:M 15 Feb 2022 05:27:55.912 * 从磁盘加载数据库耗时:0.560 秒
102:M 15 Feb 2022 05:27:55.912 * 已准备好接受连接
I, [2022-02-15T05:28:05.336548 #1] INFO -- :
I, [2022-02-15T05:28:05.337696 #1] INFO -- : > thpoff echo "thpoff is installed!"
I, [2022-02-15T05:28:05.349534 #1] INFO -- : thpoff is installed!
I, [2022-02-15T05:28:05.349959 #1] INFO -- : > /usr/local/bin/ruby -e 'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end'
I, [2022-02-15T05:28:05.496038 #1] INFO -- :
I, [2022-02-15T05:28:05.496604 #1] INFO -- : > /usr/local/bin/ruby -e 'if ENV["DISCOURSE_HOSTNAME"] == "discourse.example.com"; puts "Aborting! Domain is not configured!"; exit 1; end'
I, [2022-02-15T05:28:05.617847 #1] INFO -- :
I, [2022-02-15T05:28:05.618268 #1] INFO -- : > /usr/local/bin/ruby -e 'if (ENV["DISCOURSE_CDN_URL"] || "")[0..1] == "//"; puts "Aborting! CDN must have a protocol specified. Once fixed you should rebake your posts now to correct all posts."; exit 1; end'
I, [2022-02-15T05:28:05.754370 #1] INFO -- :
I, [2022-02-15T05:28:05.755864 #1] INFO -- : > rm -f /etc/cron.d/anacron
I, [2022-02-15T05:28:05.763371 #1] INFO -- :
I, [2022-02-15T05:28:05.773372 #1] INFO -- : 文件 > /etc/cron.d/anacron chmod: chown:
I, [2022-02-15T05:28:05.785161 #1] INFO -- : 文件 > /etc/runit/1.d/copy-env chmod: +x chown:
I, [2022-02-15T05:28:05.801026 #1] INFO -- : 文件 > /etc/service/unicorn/run chmod: +x chown:
I, [2022-02-15T05:28:05.816469 #1] INFO -- : 文件 > /etc/service/nginx/run chmod: +x chown:
I, [2022-02-15T05:28:05.828667 #1] INFO -- : 文件 > /etc/runit/3.d/01-nginx chmod: +x chown:
I, [2022-02-15T05:28:05.841176 #1] INFO -- : 文件 > /etc/runit/3.d/02-unicorn chmod: +x chown:
I, [2022-02-15T05:28:05.841464 #1] INFO -- : 在 /etc/service/unicorn/run 中将 # postgres 替换为 sv start postgres || exit 1
I, [2022-02-15T05:28:05.842241 #1] INFO -- : > exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
I, [2022-02-15T05:28:05.847862 #1] INFO -- : > cd /var/www/discourse && git reset --hard
130:C 15 Feb 2022 05:28:05.853 # oO0OoO0OoO0Oo Redis 正在启动 oO0OoO0OoO0Oo
130:C 15 Feb 2022 05:28:05.854 # Redis 版本=6.2.6, 位宽=64, 提交=00000000, 修改=0, pid=130, 刚刚启动
130:C 15 Feb 2022 05:28:05.855 # 配置已加载
130:M 15 Feb 2022 05:28:05.857 * 单调时钟:POSIX clock_gettime
130:M 15 Feb 2022 05:28:05.858 # 警告:无法创建服务器 TCP 监听套接字 *:6379: bind: 地址已在使用中
130:M 15 Feb 2022 05:28:05.859 # 监听端口 6379 (TCP) 失败,正在中止。
正在更新文件:100% (30947/30947),完成。
I, [2022-02-15T05:28:13.624544 #1] INFO -- : HEAD 现在位于 e1367cde I18N: 改进被屏蔽单词错误消息的文案 (#15741)
I, [2022-02-15T05:29:36.205328 #1] INFO -- : > cd /var/www/discourse && [ ! -d 'node_modules' ] || su discourse -c 'yarn install --production && yarn cache clean'
警告:解析字段 "lodash@4.17.21" 与请求的版本 "lodash@4.17.15" 不兼容。
警告:" > @mixer/parallel-prettier@2.0.1" 缺少对等依赖项 "prettier@^2.0.0"。
I, [2022-02-15T05:33:01.692668 #1] INFO -- : yarn install v1.22.17
[1/5] 验证 package.json...
[2/5] 解析依赖包...
[3/5] 获取依赖包...
[4/5] 链接依赖项...
[5/5] 构建新包...
$ yarn --cwd app/assets/javascripts/discourse
yarn install v1.22.17
[1/4] 解析依赖包...
[2/4] 获取依赖包...
[3/4] 链接依赖项...
[4/4] 构建新包...
success 锁文件已保存。
Done in 133.99s.
Done in 195.02s.
yarn cache v1.22.17
success 缓存已清除。
Done in 9.35s.
I, [2022-02-15T05:33:01.697905 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all'
I, [2022-02-15T05:33:12.324517 #1] INFO -- : discourse-github 已是最新兼容版本
discourse-solved 已是最新兼容版本
discourse-chat 已是最新兼容版本
I, [2022-02-15T05:33:12.325695 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
102:M 15 Feb 2022 05:33:37.418 * 300 秒内发生 100 次更改。正在保存...
102:M 15 Feb 2022 05:33:37.423 * 后台保存已由 pid 1143 启动
1143:C 15 Feb 2022 05:33:38.349 * 数据库已保存到磁盘
1143:C 15 Feb 2022 05:33:38.352 * RDB: 复制写入使用了 2 MB 内存
102:M 15 Feb 2022 05:33:38.429 * 后台保存成功终止
I, [2022-02-15T05:33:38.994811 #1] INFO -- : gem install sawyer -v 0.8.2 -i /var/www/discourse/plugins/discourse-github/gems/2.7.5 --no-document --ignore-dependencies --no-user-install
Successfully installed sawyer-0.8.2
1 gem installed
gem install octokit -v 4.21.0 -i /var/www/discourse/plugins/discourse-github/gems/2.7.5 --no-document --ignore-dependencies --no-user-install
Successfully installed octokit-4.21.0
1 gem installed
== 20220214224506 ResetCustomEmojiPostBakesVersionSecureFix: migrating ========
== 20220214224506 ResetCustomEmojiPostBakesVersionSecureFix: migrated (0.0099s)
== 20220214233625 AddBounceErrorCodeToEmailLog: migrating =====================
-- add_column(:email_logs, :bounce_error_code, :string, {:null=true})
-> 0.0103s
== 20220214233625 AddBounceErrorCodeToEmailLog: migrated (0.0121s) ============
I, [2022-02-15T05:33:38.996639 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile'
- 正在构建
- 正在构建
- 正在构建...
102:M 15 Feb 2022 05:38:39.069 * 300 秒内发生 100 次更改。正在保存...
102:M 15 Feb 2022 05:38:39.080 * 后台保存已由 pid 1213 启动
1213:C 15 Feb 2022 05:38:39.863 * 数据库已保存到磁盘
1213:C 15 Feb 2022 05:38:39.867 * RDB: 复制写入使用了 2 MB 内存
102:M 15 Feb 2022 05:38:39.883 * 后台保存成功终止
[WARN] (broccoli-terser-sourcemap) 压缩 "assets/discourse.js" 耗时:35001 毫秒(超过 20,000 毫秒)
Killed
error 命令失败,退出代码 137。
I, [2022-02-15T05:52:50.058283 #1] INFO -- : yarn run v1.22.17
$ /var/www/discourse/app/assets/javascripts/node_modules/.bin/ember build -prod
警告:Node v16.13.2 未针对您的平台上的 Ember CLI 进行测试。我们建议您使用最新的「Active LTS」版本的 Node.js。详见 https://git.io/v7S5n。
弃用警告:jQuery 集成到 Ember 中已被弃用,并将在 Ember 4.0 中移除。您可以选择不使用 jQuery,或者安装 `@ember/jquery` 插件以提供 jQuery 集成。请参阅弃用指南以获取更多详情:https://emberjs.com/deprecations/v3.x#toc_jquery-apis
环境:production
有关此命令的文档,请访问 https://yarnpkg.com/en/docs/cli/run
I, [2022-02-15T05:52:50.072549 #1] INFO -- : 正在终止异步进程
I, [2022-02-15T05:52:50.072816 #1] INFO -- : 向 HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41 发送 INT
I, [2022-02-15T05:52:50.073275 #1] INFO -- : 向 exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 102 发送 TERM
102:signal-handler (1644904370) 收到 SIGTERM,正在调度关闭...
2022-02-15 05:52:50.074 UTC [41] LOG: 收到快速关闭请求
2022-02-15 05:52:50.090 UTC [41] LOG: 中止任何活跃事务
2022-02-15 05:52:50.096 UTC [41] LOG: 后台工作进程 "logical replication launcher" (PID 50) 以退出代码 1 退出
2022-02-15 05:52:50.102 UTC [45] LOG: 正在关闭
102:M 15 Feb 2022 05:52:50.118 # 用户请求关闭...
102:M 15 Feb 2022 05:52:50.120 * 在退出前保存最终的 RDB 快照。
2022-02-15 05:52:50.248 UTC [41] LOG: 数据库系统已关闭
102:M 15 Feb 2022 05:52:51.075 * 数据库已保存到磁盘
102:M 15 Feb 2022 05:52:51.076 # Redis 现在准备退出,再见...
失败
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' 失败,返回 #<Process::Status: pid 1144 exit 137>
失败位置:/usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
执行失败,参数为 {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
1716fd9590e21cdfdaccea0ac6faabd133a6423e1a24ef3b3b5be0e68ce422c9
** 引导失败 ** 请向上滚动查看更早的错误消息,可能不止一条。
./discourse-doctor 可能有助于诊断问题。
正在运行 discourse-doctor,并收集更详细的日志。
这是我制作并已成功使用一年或更长时间的升级脚本:
https://github.com/balupton/dotfiles/blob/master/commands/discourse-upgrader