이 문제로 인해 빌드가 실패했습니다. ENV 변수를 제거하고 이를 사용하지 않은 상태로 다시 빌드했습니다. 그런 다음 컨테이너 안에서 디버깅을 시작했습니다. discourse.conf에 키를 추가했는데도 여전히 실패합니다.
(다행히도 클라이언트에게 잘못된 키를 제공했다고 알리기 전에 이 작업을 수행했습니다!)
rake 태스크에 puts를 추가하여 데이터베이스를 다운로드하려고 하는 URL을 다음과 같이 출력하도록 했습니다:
url =
"https://download.maxmind.com/app/geoip_download?license_key=#{GlobalSetting.maxmind_license_key}&edition_id=#{name}&suffix=tar.gz"
gz_file =
FileHelper.download(
url,
max_file_size: 100.megabytes,
tmp_file_name: "#{name}.gz",
validate_uri: false,
follow_redirect: false,
)
if gz_file.nil?
puts "no gzfile"
end
puts "Got file #{gz_file} for #{url}"
filename = File.basename(gz_file.path)
이제 다음과 같은 결과를 얻습니다:
root@web-only:/var/www/discourse# rake maxminddb:get
Plugin name is 'discourse-topic-voting', but plugin directory is named 'discourse-voting'
Downloading MaxMindDb's GeoLite2-City...
no gzfile
Got file for https://download.maxmind.com/app/geoip_download?license_key=VALID_KEY_IS_HERE&edition_id=GeoLite2-City&suffix=tar.gz
rake aborted!
NoMethodError: undefined method `path' for nil:NilClass (NoMethodError)
filename = File.basename(gz_file.path)
^^^^^
/var/www/discourse/lib/discourse_ip_info.rb:52:in `mmdb_download'
/var/www/discourse/lib/tasks/maxminddb.rake:9:in `block (2 levels) in <main>'
/var/www/discourse/lib/tasks/maxminddb.rake:7:in `each'
/var/www/discourse/lib/tasks/maxminddb.rake:7:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => maxminddb:get
(See full trace by running task with --trace)
Maxmind에 의해 사이트가 차단되어 문제가 발생한 다른 토픽이 있어서, 해당 서버의 컨테이너 안에서 wget을 사용하여 해당 URL을 성공적으로 다운로드해 보았습니다.
FileHelper.download는 결국 Helper가 아니라, 파일 대신 nil을 조용히 반환하는 것 같습니다. 파일은 단 44MB이므로 용량 문제가 아닙니다. wget으로 전체 헤더를 확인해 봤을 때 리다이렉트는 보이지 않습니다.
이것이 어떤 문제일 수 있는지 아이디어가 있을까요?
이 에러를 잡아(invalid key로 빌드가 완료되도록) 처리하지 않는 이유가 있을까요? 아마 경고만 출력하면 되지 않을까요?
Downloading MaxMindDB...
Compressing Javascript and Generating Source Maps
I, [2024-03-26T13:27:38.305597 #1] INFO -- : Terminating async processes
I, [2024-03-26T13:27:38.307312 #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: 42
I, [2024-03-26T13:27:38.307891 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 111
111:signal-handler (1711459658) Received SIGTERM scheduling shutdown...
2024-03-26 13:27:38.307 UTC [42] LOG: received fast shutdown request
2024-03-26 13:27:38.314 UTC [42] LOG: aborting any active transactions
2024-03-26 13:27:38.321 UTC [42] LOG: background worker "logical replication launcher" (PID 51) exited with exit code 1
2024-03-26 13:27:38.322 UTC [46] LOG: shutting down
111:M 26 Mar 2024 13:27:38.353 # User requested shutdown...
111:M 26 Mar 2024 13:27:38.353 * Saving the final RDB snapshot before exiting.
2024-03-26 13:27:38.415 UTC [42] LOG: database system is shut down
111:M 26 Mar 2024 13:27:39.896 * DB saved on disk
111:M 26 Mar 2024 13:27:39.896 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 3889 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
bootstrap failed with exit code 1
** 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.
fe4eec7726fdbe08aaa2691e806bb17423a8f4eaedb8414397e3097d725e04c7