I accidentally deleted our app.yaml file


(Quincy Larson) #1

I SSH’d into the server, opened the app.yml using nano, and attempted to copy everything out so I could have a backup copy. It turns out my backup copy was truncated and I lost everything above this line (and yes, I pasted the mangled code in and saved it, not realizing it was truncated):

  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## The docker manager plugin allows you to one-click upgrade Discourse
## http://forum.freecodecamp.com/admin/docker
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Remember, this is YAML syntax - you can only have one block with a name
run:
  - exec: echo "Beginning of custom commands"

  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  ## After getting the first signup email, re-comment the line. It only needs to run once.

  ## If you want to configure password login for root, uncomment and change:
  ## Use only one of the following lines:
  #- exec: /usr/sbin/usermod -p 'PASSWORD_HASH' root
  #- exec: /usr/sbin/usermod -p "$(mkpasswd -m sha-256 'RAW_PASSWORD')" root

  - exec: echo "End of custom commands"

Here’s what I’ve tried: creating a new Digital Ocean instance, copying its app.yml, updating it accordingly to the best of my abilities and pasting it in.

I am still getting the following errors:

2016-11-09 05:21:42 UTC [54-1] postgres@postgres ERROR:  database "discourse" already exists
2016-11-09 05:21:42 UTC [54-2] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: database creation failed: ERROR:  database "discourse" already exists

and

I, [2016-11-09T05:21:57.982696 #13]  INFO -- : 
I, [2016-11-09T05:21:57.982940 #13]  INFO -- : > cd /var/www/discourse && bash -c "touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log"
I, [2016-11-09T05:21:57.987517 #13]  INFO -- : 
I, [2016-11-09T05:21:57.987819 #13]  INFO -- : > cd /var/www/discourse && bash -c "ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr}.log /var/www/discourse/log"

Which ends in this:

I, [2016-11-09T05:28:26.158932 #13]  INFO -- : Purging temp files
Bundling assets
Compressing Javascript and Generating Source Maps

I, [2016-11-09T05:28:26.176039 #13]  INFO -- : File > /usr/local/bin/discourse  chmod: +x
I, [2016-11-09T05:28:26.182901 #13]  INFO -- : File > /usr/local/bin/rails  chmod: +x
I, [2016-11-09T05:28:26.188062 #13]  INFO -- : File > /usr/local/bin/rake  chmod: +x
I, [2016-11-09T05:28:26.193387 #13]  INFO -- : File > /etc/update-motd.d/10-web  chmod: +x
I, [2016-11-09T05:28:26.196390 #13]  INFO -- : File > /etc/logrotate.d/rails  chmod: 
I, [2016-11-09T05:28:26.198889 #13]  INFO -- : File > /etc/logrotate.d/nginx  chmod: 
I, [2016-11-09T05:28:26.203369 #13]  INFO -- : File > /etc/runit/1.d/00-ensure-links  chmod: +x
I, [2016-11-09T05:28:26.207612 #13]  INFO -- : File > /root/.bash_profile  chmod: 644
I, [2016-11-09T05:28:26.208931 #13]  INFO -- : Replacing (?-mix:server.+{) with limit_req_zone $binary_remote_addr zone=flood:10m rate=$reqs_per_secondr/s;
limit_req_zone $binary_remote_addr zone=bot:10m rate=$reqs_per_minuter/m;
limit_req_status 429;
server {
 in /etc/nginx/conf.d/discourse.conf
I, [2016-11-09T05:28:26.209512 #13]  INFO -- : Replacing (?-mix:location @discourse {) with location @discourse {
  limit_req zone=flood burst=$burst_per_second nodelay;
  limit_req zone=bot burst=$burst_per_minute nodelay; in /etc/nginx/conf.d/discourse.conf
I, [2016-11-09T05:28:26.210119 #13]  INFO -- : > echo "Beginning of custom commands"
I, [2016-11-09T05:28:26.212130 #13]  INFO -- : Beginning of custom commands

I, [2016-11-09T05:28:26.212312 #13]  INFO -- : > echo "End of custom commands"
I, [2016-11-09T05:28:26.213933 #13]  INFO -- : End of custom commands

I, [2016-11-09T05:28:26.214102 #13]  INFO -- : Terminating async processes
I, [2016-11-09T05:28:26.214178 #13]  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/9.5/bin/postmaster -D /etc/postgresql/9.5/main pid: 42
I, [2016-11-09T05:28:26.214310 #13]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 155
1552016-11-09 05:28:26 UTC [42-2] LOG:  received fast shutdown request
2016-11-09 05:28:26 UTC [42-3] LOG:  aborting any active transactions
2016-11-09 05:28:26 UTC [49-2] LOG:  autovacuum launcher shutting down
2016-11-09 05:28:26 UTC [46-1] LOG:  shutting down
:signal-handler (1478669306) Received SIGTERM scheduling shutdown...
2016-11-09 05:28:26 UTC [46-2] LOG:  database system is shut down
155:M 09 Nov 05:28:26.301 # User requested shutdown...
155:M 09 Nov 05:28:26.302 * Saving the final RDB snapshot before exiting.
155:M 09 Nov 05:28:30.033 * DB saved on disk
155:M 09 Nov 05:28:30.033 # Redis is now ready to exit, bye bye...

(Quincy Larson) #2

OK - I waited a bit longer and the launcher task finished. Our Discourse instance is now working again, the version is now updated, and the plugins I added are now available!

The only problem is I’m getting this error:

Am I correct to assume this is related to the app.yml file?


(Jeff Atwood) #3

Great! Excellent recovery! You may want to double check your mail settings in the app.yml file to make sure all is well there.


(Jay Pfaffman) #4

Nice work. Another solution, if your setup is pretty simple (and you don’t appear to have any plugins installed), is to just delete app.yml and run ./discourse-setup again.

Among the first things that it does is

cp samples/standalone.yml app.yml

so one could do that and then edit app.yml with nano like the old days.