Rebuild app crashes every time :(


(Filippo) #1

Hi,
I’m trying to rebuild a discourse that I have to change the port where it connects. It gives always this error when I launch the discourse_setup. Any idea of the reason why?

I, [2018-11-07T10:52:46.331960 #14]  INFO -- : Loading --stdin
I, [2018-11-07T10:52:46.337198 #14]  INFO -- : > locale-gen $LANG && update-locale
I, [2018-11-07T10:52:47.317933 #14]  INFO -- : Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

I, [2018-11-07T10:52:47.318818 #14]  INFO -- : > mkdir -p /shared/postgres_run
I, [2018-11-07T10:52:47.323093 #14]  INFO -- :
I, [2018-11-07T10:52:47.323458 #14]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2018-11-07T10:52:47.327843 #14]  INFO -- :
I, [2018-11-07T10:52:47.328217 #14]  INFO -- : > chmod 775 /shared/postgres_run
I, [2018-11-07T10:52:47.331105 #14]  INFO -- :
I, [2018-11-07T10:52:47.331469 #14]  INFO -- : > rm -fr /var/run/postgresql
I, [2018-11-07T10:52:47.335344 #14]  INFO -- :
I, [2018-11-07T10:52:47.335668 #14]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2018-11-07T10:52:47.338294 #14]  INFO -- :
I, [2018-11-07T10:52:47.338610 #14]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2018/11/07 10:52:47 socat[46] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2018-11-07T10:52:47.359290 #14]  INFO -- :
I, [2018-11-07T10:52:47.359586 #14]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2018-11-07T10:52:47.361873 #14]  INFO -- :
I, [2018-11-07T10:52:47.362154 #14]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2018-11-07T10:52:47.363789 #14]  INFO -- :
I, [2018-11-07T10:52:47.364068 #14]  INFO -- : > mkdir -p /shared/postgres_run/10-main.pg_stat_tmp
I, [2018-11-07T10:52:47.365414 #14]  INFO -- :
I, [2018-11-07T10:52:47.365755 #14]  INFO -- : > chown postgres:postgres /shared/postgres_run/10-main.pg_stat_tmp
I, [2018-11-07T10:52:47.367216 #14]  INFO -- :
I, [2018-11-07T10:52:47.370687 #14]  INFO -- : File > /etc/service/postgres/run  chmod: +x
I, [2018-11-07T10:52:47.373525 #14]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x
I, [2018-11-07T10:52:47.377245 #14]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x
I, [2018-11-07T10:52:47.380420 #14]  INFO -- : File > /root/upgrade_postgres  chmod: +x
I, [2018-11-07T10:52:47.380803 #14]  INFO -- : > chown -R root /var/lib/postgresql/10/main
I, [2018-11-07T10:52:49.615030 #14]  INFO -- :
I, [2018-11-07T10:52:49.615642 #14]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/10/bin/initdb -D /shared/postgres_data || exit 0
I, [2018-11-07T10:52:49.617295 #14]  INFO -- :
I, [2018-11-07T10:52:49.617531 #14]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2018-11-07T10:52:49.671179 #14]  INFO -- :
I, [2018-11-07T10:52:49.671651 #14]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2018-11-07T10:52:49.673376 #14]  INFO -- :
I, [2018-11-07T10:52:49.673775 #14]  INFO -- : > /root/upgrade_postgres
I, [2018-11-07T10:52:49.680547 #14]  INFO -- :
I, [2018-11-07T10:52:49.680823 #14]  INFO -- : > rm /root/upgrade_postgres
I, [2018-11-07T10:52:49.682012 #14]  INFO -- :
I, [2018-11-07T10:52:49.684255 #14]  INFO -- : Replacing data_directory = '/var/lib/postgresql/10/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.684831 #14]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.685703 #14]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.686370 #14]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.687144 #14]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.687794 #14]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.688538 #14]  INFO -- : > install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
I, [2018-11-07T10:52:49.693970 #14]  INFO -- :
I, [2018-11-07T10:52:49.694372 #14]  INFO -- : Replacing (?-mix:#?max_wal_senders *=.*) with max_wal_senders = $db_max_wal_senders in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.694814 #14]  INFO -- : Replacing (?-mix:#?wal_level *=.*) with wal_level = $db_wal_level in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.695581 #14]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.696350 #14]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.697122 #14]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/10/main/postgresql.conf
I, [2018-11-07T10:52:49.698374 #14]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/10/main/pg_hba.conf
I, [2018-11-07T10:52:49.698767 #14]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/10/main/pg_hba.conf
I, [2018-11-07T10:52:49.699379 #14]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/10/bin/postmaster -D /etc/postgresql/10/main
I, [2018-11-07T10:52:49.700335 #14]  INFO -- : > sleep 5
2018-11-07 10:52:49.817 UTC [69] FATAL:  data directory "/shared/postgres_data" has group or world access
2018-11-07 10:52:49.817 UTC [69] DETAIL:  Permissions should be u=rwx (0700).
I, [2018-11-07T10:52:54.703603 #14]  INFO -- :
I, [2018-11-07T10:52:54.704237 #14]  INFO -- : > su postgres -c 'createdb discourse' || true
createdb: could not connect to database template1: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I, [2018-11-07T10:52:54.798068 #14]  INFO -- :
I, [2018-11-07T10:52:54.798442 #14]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I, [2018-11-07T10:52:54.858517 #14]  INFO -- :
I, [2018-11-07T10:52:54.858844 #14]  INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I, [2018-11-07T10:52:54.905524 #14]  INFO -- :
I, [2018-11-07T10:52:54.905887 #14]  INFO -- : > su postgres -c 'psql discourse -c "alter schema public owner to discourse;"'
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I, [2018-11-07T10:52:54.952361 #14]  INFO -- :
I, [2018-11-07T10:52:54.952801 #14]  INFO -- : Terminating async processes


FAILED
--------------------
Pups::ExecError: su postgres -c 'psql discourse -c "alter schema public owner to discourse;"' failed with return #<Process::Status: pid 95 exit 2>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "su postgres -c 'psql $db_name -c \"alter schema public owner to $db_user;\"'"
ec6a6e543e5cf2fd213b11eae2ada521cd75849cdfd7eff1b4d171f303756fe1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

Thanks!


(Rafael dos Santos Silva) #2

Key here is those lines.

You gotta fix the permissions in that folder.


(Filippo) #3

Thank you! The question now is… where?

Since I’m trying to run a docker container… what container is going to be start with the rebuild? Or where do I find that folder? Since in the filesystem I don’t have that path.


(Rafael dos Santos Silva) #4

That defaults to be inside /var/discourse/shared/standalone/.

You can check actual values in the /var/discourse/containers/app.yml in the section volumes.


(Filippo) #5

If I set the permissions to 0700 I get:

2018-11-07 11:31:56.728 GMT [69] LOG:  skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2018-11-07 11:31:56.730 UTC [69] FATAL:  could not read permissions of directory "/shared/postgres_data": Permission denied

:frowning: ideas?


(Rafael dos Santos Silva) #6

I think you changed the owner of the folder too. Why did you make such changes? Was something broken?


(Filippo) #7

It worked when I put the recursive flag to chmod :slight_smile: thank you.


(Régis Hanol) #8