Fail to rebuild and got 502 Bad Gateway

(xiasummer) #1

with error info

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle install --deployment --verbose --without test --without development' failed with return #<Process::Status: pid 359 exit 7>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

As it said I should read the former lines for more error messages, I checked the message in ./launcher rebuild app and found the only more message is

2017-08-20 04:27:13.878 UTC [56] postgres@postgres ERROR:  database "discourse" already exists
2017-08-20 04:27:13.878 UTC [56] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: database creation failed: ERROR:  database "discourse" already exists
I, [2017-08-20T04:27:13.880744 #15]  INFO -- :
I, [2017-08-20T04:27:13.881052 #15]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2017-08-20 04:27:13.966 UTC [67] postgres@discourse ERROR:  role "discourse" already exists
2017-08-20 04:27:13.966 UTC [67] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists

And here is the docker ps that might help.

 docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                                   NAMES
f8b075b4656b        sameersbn/gitlab:latest       "/sbin/entrypoint...."   3 months ago        Up 21 minutes       443/tcp,>22/tcp,>80/tcp   gitlab_gitlab_1
d2dd063db080        sameersbn/redis:latest        "/sbin/entrypoint...."   11 months ago       Up 21 minutes       6379/tcp                                                gitlab_redis_1
e875efc4b0b5        sameersbn/postgresql:9.4-21   "/sbin/"    11 months ago       Up 21 minutes       5432/tcp                                                gitlab_postgresql_1

Could you please help me?

I checked meta, and found some perhaps similar answers, but I tried rebooted the server, and nothing happened.

Is it because this is a server in China, and now some of the websites are blocked by the great Chinese firewall?

What’s more

It’s not only not rebuildable, but also the server encounters 502 Badgateway(nginx) error.

I checked the docker is running.

I restarted the discourse, rebooted the server, but still nothing happened.

(xiasummer) #2

Any one can help? It’s quite urgent.

(Eli the Bearded) #3

The rebuild command produces a lot of output. You have not included it all, or enough to say where the problem may lay.

Checking, I see my last failed rebuild had 280 lines of output.

(xiasummer) #4

Hi, you asked for the whole message

total_message.txt.gz (46.9 KB)


and I found a very similar problem which was caused by the source of ruby china.

Failed to rebuild Discourse with the following information

Line 2584 in your log file:

Your bundle is locked to message_bus (2.0.5), but that version could not be
found in any of the sources listed in your Gemfile. If you haven’t changed
sources, that means the author of message_bus (2.0.5) has removed it. You’ll
need to update your bundle to a different version of message_bus (2.0.5) that
hasn’t been removed in order to install.

So you’re correct that this is caused by the RubyGem mirror you’re using.

Running the following should remove the bundler mirror config.

bundle config --delete mirror.

Here is the official doc on using mirrors with bundler.

(xiasummer) #6

Thank you very much. I got all the problems done with the help of a Chinese friend.

That is because of the ruby source in China is not up to date.

And the solving is delete the line in app.yml


Rebuild you will solve such problems.