Problem setup on AWS: EC2, RDS, ElastiCache

Hi,

I have been following this guide to install Discourse on whole AWS services.

EC2 for Instance, RDS for Database, ElastiCache for Redis, Cloudfront for CDN and finally SES for Emails.

No problem for Cloudfront and SES.

However, I am having issues at build. Here’s logs when I do ./launcher rebuild app or ./launcher bootstrap app

Logs

I, [2016-11-07T19:31:18.480826 #13] INFO – : > cd /var/www/discourse && su discourse -c ‘bundle exec rake db:migrate’
Failed to report error: Name or service not known 2 Name or service not known subscribe failed, reconnecting in 1 second. Call stack ["/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/connection/hiredis.rb:19:in connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/connection/hiredis.rb:19:in connect’", “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:336:in establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:101:in block in connect’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:293:in with_reconnect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:100:in connect’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:276:in with_socket_timeout'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/client.rb:133:in call_loop’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/subscribe.rb:43:in subscription'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis/subscribe.rb:12:in subscribe’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis.rb:2760:in _subscription'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis.rb:2138:in block in subscribe’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis.rb:58:in block in synchronize'", "/usr/local/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis.rb:58:in synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.1/lib/redis.rb:2137:in subscribe’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.2/lib/message_bus/backends/redis.rb:304:in global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.2/lib/message_bus.rb:513:in global_subscribe_thread’”, “/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.2/lib/message_bus.rb:461:in `block in new_subscriber_thread’”]
URGENT: could not translate host name “censored_endpoint:5432” to address: Name or service not known
Failed to initialize site default
rake aborted!
Name or service not known

(…)

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c ‘bundle exec rake db:migrate’ failed with return #<Process::Status: pid 844 exit 1>
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’”]}
f84cadbb62af834c90c52ee65e80d069b259bd28a387223fc2f9d5c608046478
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

Here’s app.yml config:

app.yml
## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
## - "templates/postgres.template.yml"
## - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "128MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 2

  ## TODO: configure connectivity to the databases
  DISCOURSE_DB_SOCKET: ''
  DISCOURSE_DB_NAME: discourse
  DISCOURSE_DB_POOL: 15
  DISCOURSE_DB_USERNAME: discourse
  DISCOURSE_DB_PASSWORD: censored
  DISCOURSE_DB_HOST: 'censored_endpoint:5432'
  DISCOURSE_REDIS_HOST: 'censored_endpoint:6379'
  ## TODO: The domain name this Discourse instance will respond to
  DISCOURSE_HOSTNAME: 'censored'

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'censored'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  DISCOURSE_SMTP_ADDRESS: email-smtp.eu-west-1.amazonaws.com         # required
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: censored
  DISCOURSE_SMTP_PASSWORD: censored
  DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: censored

  ## The CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  DISCOURSE_CDN_URL: //censored

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/web-only
  guest: /shared
  - volume:
  host: /var/discourse/shared/web-only/log/var-log
  guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
- exec:
    cd: $home/plugins
    cmd:
      - git clone https://github.com/discourse/docker_manager.git

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

AWS is all set. Neither I think it’s AWS side. Please help :slight_smile:

Fixed on my own.

I thought I had no mistakes from AWS side however my Redis was not configured correctly and I had also used configure endpoint in app.yml. Damn, how did I miss that, it should’ve been primary endpoint :smiley:

I have also added two more lines to app.yml and maybe they were also part of this trick.

4 Likes

Thank you… this worked for me!!