업그레이드 후 다운: yarn not found

자체 호스팅 Discourse 인스턴스 forum.embeetle.com을 업그레이드하려고 시도하던 중:

git pull
./launcher rebuild app

다음과 같은 오류가 발생했습니다:

sh: 1: yarn: not found

그리고 포럼이 다운되었습니다.

이 문제는 유사해 보이지만(이것도 yarn: not found를 언급함), 제가 적용할 수 있는 해결책을 제공하지 않습니다:

./launcher rebuild app 출력의 마지막 부분(오류를 포함하여)은 다음과 같습니다:

I, [2022-04-15T12:58:22.640335 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake plugin:pull_compatible_all'
WARNING: Plugins were activated before running `rake plugin:pull_compatible_all`
  You should prefix this command with LOAD_PLUGINS=0
I, [2022-04-15T12:58:28.725935 #1]  INFO -- : discourse-bbcode-color is already at latest compatible version
docker_manager is already at latest compatible version
discourse-math is already at latest compatible version

I, [2022-04-15T12:58:28.726300 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
I, [2022-04-15T12:58:35.125132 #1]  INFO -- : 
I, [2022-04-15T12:58:35.125478 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile'
sh: 1: yarn: not found
I, [2022-04-15T12:58:39.396023 #1]  INFO -- : Checking 'Tag Icons' for 'default'... 
I, [2022-04-15T12:58:39.396636 #1]  INFO -- : Terminating async processes
I, [2022-04-15T12:58:39.396757 #1]  INFO -- : Sending INT to 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: 57
I, [2022-04-15T12:58:39.396823 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 174
2022-04-15 12:58:39.396 UTC [57] LOG:  received fast shutdown request
174:signal-handler (1650027519) Received SIGTERM scheduling shutdown...
174:M 15 Apr 2022 12:58:39.399 # User requested shutdown...
174:M 15 Apr 2022 12:58:39.399 * Saving the final RDB snapshot before exiting.
2022-04-15 12:58:39.416 UTC [57] LOG:  aborting any active transactions
174:M 15 Apr 2022 12:58:39.417 * DB saved on disk
174:M 15 Apr 2022 12:58:39.417 # Redis is now ready to exit, bye bye...
2022-04-15 12:58:39.418 UTC [57] LOG:  background worker "logical replication launcher" (PID 66) exited with exit code 1
2022-04-15 12:58:39.421 UTC [61] LOG:  shutting down
2022-04-15 12:58:39.544 UTC [57] LOG:  database system is shut down

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 5379 exit 127>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
13c38843d2b7e10b51c38f0d998f9e6e1c84fec93c7fc2ab2c044834ee6a8e59
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

discourse-doctor의 출력이 여기 게시하기에 너무 크므로, 제 눈에 가장 중요해 보이는 부분을 포함합니다:

root@foechoer:/srv/embeetle_forum/discourse# ./discourse-doctor
DISCOURSE DOCTOR Fri Apr 15 14:59:02 CEST 2022
OS: Linux foechoer.sikando.com 4.15.0-142-generic #146-Ubuntu SMP Tue Apr 13 01:11:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


Found containers/app.yml

==================== YML SETTINGS ====================
DISCOURSE_HOSTNAME=forum.embeetle.com
SMTP_ADDRESS=smtp.zoho.com #mail.embeetle.com
DEVELOPER_EMAILS=johan@embeetle.com,kristof@embeetle.com,matic@embeetle.com
SMTP_PASSWORD=PASSWORD
SMTP_PORT=587
SMTP_USER_NAME=forum@embedeer.com
LETSENCRYPT_ACCOUNT_EMAIL=postmaster@sikando.com

==================== DOCKER INFO ====================
DOCKER VERSION: Docker version 20.10.14, build a224086

DOCKER PROCESSES (docker ps -a)

CONTAINER ID   IMAGE                              COMMAND                  CREATED         STATUS                     PORTS      NAMES
f972c6ac40db   nginx:latest                       "/docker-entrypoint.…"   16 hours ago    Up 16 hours                80/tcp     docker_chipselect_1
b8eaa7fc632d   docker_cs_php                      "docker-php-entrypoi…"   16 hours ago    Up 16 hours                9000/tcp   docker_cs_php_1
51c18c3af7d2   mariadb:latest                     "docker-entrypoint.s…"   16 hours ago    Up 16 hours                3306/tcp   docker_cs_mysql_1
b018a429fc83   hello-world                        "/hello"                 3 days ago      Exited (0) 3 days ago                 blissful_wiles
f4064f10924a   local_discourse/app                "/sbin/boot"             11 months ago   Exited (5) 2 minutes ago              app
bff8181744a2   discourse/base:2.0.20210415-1332   "/bin/bash -c 'cd /p…"   11 months ago   Exited (0) 11 months ago              vigilant_einstein
fb6cca53886d   discourse/base:2.0.20210415-1332   "/bin/bash -c 'cd /p…"   11 months ago   Exited (0) 11 months ago              gifted_mclaren
ea974bead75f   discourse/base:2.0.20201221-2020   "/bin/bash -c 'cd /p…"   13 months ago   Exited (0) 13 months ago              ecstatic_margulis

==================== SERIOUS PROBLEM!!!! ====================
app not running!
Attempting to rebuild
==================== REBUILD LOG ====================

...(omitted long output)...

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 5379 exit 127>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
1fc0ce85c275da0c2c9f39bc496581b4a5a80f0888378733e1e6e177698dc110
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
==================== END REBUILD LOG ====================
Failed to rebuild app.

Checking your domain name . . .

Connection to forum.embeetle.com succeeded.
You should probably remove any non-standard plugins and rebuild.
Attempting to restart existing container. . . 

starting up existing container
+ /usr/bin/docker start app
app
f4064f10924a   local_discourse/app   "/sbin/boot"             11 months ago   Up Less than a second              app
Restarted the container.


==================== PLUGINS ====================
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-math.git
          - git clone https://github.com/discourse/discourse-bbcode-color.git

No non-official plugins detected.

See https://github.com/discourse/discourse/blob/master/lib/plugin/metadata.rb for the official list.

========================================
Discourse version at forum.embeetle.com: NOT FOUND
Discourse version at localhost: NOT FOUND


==================== MEMORY INFORMATION ====================
RAM (MB): 20553

              total        used        free      shared  buff/cache   available
Mem:          20071        4444        9431         292        6195       15517
Swap:          2047          96        1951

==================== DISK SPACE CHECK ====================
---------- OS Disk Space ----------
df: /var/discourse: No such file or directory
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       1.4T  1.1T  279G  79% /

==================== DISK INFORMATION ====================
Disk /dev/loop0: 111.6 MiB, 117014528 bytes, 228544 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 61.9 MiB, 64901120 bytes, 126760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 43.9 MiB, 45998080 bytes, 89840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 110.6 MiB, 115986432 bytes, 226536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop5: 61.9 MiB, 64901120 bytes, 126760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop6: 43.9 MiB, 45998080 bytes, 89840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 1.4 TiB, 1503238553600 bytes, 2936012800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x645c17b2

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sda1  *       2048    1953791    1951744  953M 83 Linux
/dev/sda2       1953792 2936010751 2934056960  1.4T 83 Linux

==================== END DISK INFORMATION ====================

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [johan@embeetle.com]: 
Sending mail to johan@embeetle.com. . . 
Testing sending to johan@embeetle.com using smtp.zoho.com:587, username:forum@embedeer.com with plain auth.
SMTP server connection successful.
Sending to johan@embeetle.com. . . 
Mail accepted by SMTP server.
Message-ID: 0268f0a5-e5d3-430d-85ab-3c7f3e173487@forum.embeetle.com

If you do not receive the message, check your SPAM folder
or test again using a service like http://www.mail-tester.com/.

If the message is not delivered it is not a problem with Discourse.
Check the SMTP server logs for the above Message ID to see why it
failed to deliver the message.
Replacing: SMTP_PASSWORD
Replacing: LETSENCRYPT_ACCOUNT_EMAIL
Replacing: DEVELOPER_EMAILS
Replacing: DISCOURSE_DB_PASSWORD
Replacing: Sending mail to

==================== DONE! ====================
Would you like to serve a publicly available version of this file? (Y/n)y
Publicly available log not generated.

You can examine the output of this script with 
LESS=-Ri less /tmp/discourse-debug.txt

BUT FIRST, make sure that you know the first three commands below!!!

Commands to know when viewing the file with the above command (called 'less'): 
q              -- quit
/error<ENTER>  -- search for the word 'error'
n              -- search for the next occurrence
g              -- go to the beginning of the file
f              -- go forward a page
b              -- go back a page
G              -- go to the end of the file

다른 주제에서 발생한 오류는 올바른 토론 브랜치(master가 main으로 이름이 변경됨)를 사용하지 않아서였다고 생각합니다. 설치 프로그램이 이를 자동으로 전환해야 하지만, 그렇지 않은 사례가 몇 번 있었습니다.

검색 결과로 파악한 바로는, 다음을 시도해 볼 수 있습니다:

cd /var/discourse
git checkout main

그리고 다시 빌드를 시도해 보세요.

@pfaffman 과 @Falco 도 이 부분에 대해 저보다 훨씬 더 많은 경험을 가지고 있으므로, 그들에게도 도움을 요청해 보겠습니다. :slight_smile:

포럼이 다시 복구되었습니다.

제가 취한 조치는 다음과 같습니다:

  1. git status를 실행하여 현재 브랜치를 확인했습니다. 이미 main 브랜치였지만, 몇 시간 전에 pull을 했음에도 최신 리비전이 아니었습니다. 이유는 알 수 없습니다. 2021-08-03 20:50:04의 990519e237 “Rename master to main” 리비전에 멈춰 있었습니다.

  2. 다시 git pull을 실행했습니다. 2022-04-13 06:22:53의 2a9faf7e56 “Bump default base image” 리비전으로 이동했습니다.

  3. ./launcher rebuild app을 실행했습니다. 터미널에 매우 긴 줄(JSON처럼 보이는)이 출력되기 시작했고, 그 후 서버와의 연결이 끊어졌습니다.

  4. 서버에 다시 로그인하여 ./launcher start app을 실행했습니다. 에러는 없었지만, 포럼은 여전히 오프라인 상태였습니다.

  5. ./launcher rebuild app을 다시 시도했습니다. 이번에는 문제없이 실행되었고 포럼이 다시 온라인으로 돌아왔습니다.

기쁘지만, 여전히 무엇이 잘못되었는지 확실하지 않습니다. @JammyDodger 님이 추측하신 대로, master에서 main으로의 브랜치 이름 변경과 관련이 있을 가능성이 큽니다.