diff --git a/Makefile b/Makefile index c7f4fd3..e0da9dd 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,11 @@ test/%_test.rb: always test: always $(hain) 'cd /Sutty/sutty; RAILS_ENV=test bundle exec rake test' -serve: /etc/hosts - $(hain) 'cd /Sutty/sutty; bundle exec rails s -b "ssl://0.0.0.0:3000?key=../sutty.local/domain/$(SUTTY).key&cert=../sutty.local/domain/$(SUTTY).crt"' +postgresql: /etc/hosts + pgrep postgres >/dev/null || $(hain) postgresql + +serve: /etc/hosts postgresql + $(MAKE) rails args=server # make rails args="db:migrate" rails: @@ -129,5 +132,6 @@ ota-rb: @grep -q " $(SUTTY)$$" $@ || echo -e "127.0.0.1 $(SUTTY)\n::1 $(SUTTY)" | sudo tee -a $@ @grep -q " api.$(SUTTY)$$" $@ || echo -e "127.0.0.1 api.$(SUTTY)\n::1 api.$(SUTTY)" | sudo tee -a $@ @grep -q " panel.$(SUTTY)$$" $@ || echo -e "127.0.0.1 panel.$(SUTTY)\n::1 panel.$(SUTTY)" | sudo tee -a $@ + @grep -q " postgresql.$(SUTTY)$$" $@ || echo -e "127.0.0.1 postgresql.$(SUTTY)\n::1 postgresql.$(SUTTY)" | sudo tee -a $@ .PHONY: always diff --git a/config/database.yml b/config/database.yml index 7989a01..cd599a2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,20 +5,25 @@ # gem 'sqlite3' # default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 + adapter: postgresql + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + encoding: unicode development: <<: *default - database: db/development.sqlite3 + database: 'sutty' + host: 'postgresql.sutty.local' + user: <%= ENV['USER'] %> # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: 'sutty_test' + host: 'postgresql.sutty.local' + user: <%= ENV['USER'] %> production: adapter: postgresql @@ -26,4 +31,3 @@ production: database: <%= ENV.fetch('DATABASE') { 'sutty' } %> user: sutty host: postgresql - encoding: unicode diff --git a/config/puma.rb b/config/puma.rb index 48ff0e6..60ee5ec 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -19,8 +19,15 @@ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' # Specifies the `port` that Puma will listen on to receive requests; # default is 3000. # -# port ENV.fetch('PORT') { 3000 } -bind 'tcp://[::]:3100' +# XXX: Por alguna razón el puerto en el contenedor es históricamente +# 3100, aunque en desarrollo es 3000. En algún momento deberíamos +# establecer un solo puerto. +if ENV['RAILS_ENV'] == 'production' + bind 'tcp://[::]:3100' +else + sutty = ENV.fetch('SUTTY', 'sutty.local') + bind "ssl://[::]:3000?key=../sutty.local/domain/#{sutty}.key&cert=../sutty.local/domain/#{sutty}.crt" +end # Specifies the `environment` that Puma will run in. #