diff --git a/.env b/.env index 45d5b9539..42c1e4cc1 100644 --- a/.env +++ b/.env @@ -35,6 +35,9 @@ # Put these in .env.production or .env.development to define your dev/prod # databases. Do not define it in .env or .env.local! It will be taken as your # test database too, and rails will wipe it if you run the test suite. +# +# If you are connecting to PostgreSQL via socket, omit the hostname (e.g. +# postgresql:///danbooru2) # export DATABASE_URL="postgresql://localhost/danbooru2" # export ARCHIVE_DATABASE_URL="postgresql://localhost/archive_development" # export RO_DATABASE_URL="$DATABASE_URL" diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 6ceeb2355..f15046a3c 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,3 +1,4 @@ +set :user, "danbooru" set :rails_env, "staging" server "testbooru.donmai.us", :roles => %w(web app db), :primary => true, :user => "danbooru" diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 2a5a73b82..f005f83aa 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,9 +1,9 @@ require File.expand_path('../../state_checker', __FILE__) -StateChecker.check! +StateChecker.instance.check! Rails.application.config.action_dispatch.session = { :key => '_danbooru2_session', - :secret => StateChecker.session_secret_key + :secret => StateChecker.instance.session_secret_key } -Rails.application.config.secret_token = StateChecker.secret_token +Rails.application.config.secret_token = StateChecker.instance.secret_token diff --git a/config/secrets.yml b/config/secrets.yml index 8b54b53ee..a3d89cfec 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -20,3 +20,7 @@ test: # instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + +staging: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + \ No newline at end of file diff --git a/config/state_checker.rb b/config/state_checker.rb index a3286a143..27f49912e 100644 --- a/config/state_checker.rb +++ b/config/state_checker.rb @@ -1,5 +1,5 @@ -module StateChecker - module_function +class StateChecker + include Singleton def check! ENV["SECRET_TOKEN"].present? || check_secret_token diff --git a/config/unicorn/staging.rb b/config/unicorn/staging.rb index 61c2f483a..669dce85c 100644 --- a/config/unicorn/staging.rb +++ b/config/unicorn/staging.rb @@ -15,7 +15,7 @@ user 'danbooru', 'danbooru' working_directory app_path # Should be 'production' by default, otherwise use other env -rails_env = ENV['RAILS_ENV'] || 'production' +rails_env = ENV['RAILS_ENV'] || 'staging' # Log everything to one file stderr_path "log/unicorn.log"