biola/turnout

Unable to use custom maintenance.json file

Closed this issue · 6 comments

I created a new maintenance file in /public/maintenance.json but it doesn't seem to ever get used over the default template.

I tried regenerating all of the files, restarting and playing with app_root scoping, so I'm not sure why it's not working. Is overriding the default maintenance.json file working for anybody else?

I gave it a try in a Rails and Grape app and it seemed to be working fine. Could you post some more details about your app and how you have things set up?

Also, you could try running this and see what you get.

File.expand_path(Turnout::MaintenancePage::JSON.new.send(:custom_path))
[3] pry(main)> File.expand_path(Turnout::MaintenancePage::JSON.new.send(:custom_path))
=> "/Users/alainmeier/Projects/blockscore-api/[#<Pathname:/Users/alainmeier/Projects/blockscore-api>, {:default=>\"tmp/maintenance.yml\"}, Turnout::MaintenancePage::JSON, \"The API is temporarily down for maintenance. Please visit status.blockscore.com for updates.\", 503]/public/maintenance.json"

I guess this explains it...

Yes, that's definitely a problem. That should be "/Users/alainmeier/Projects/blockscore-api/public/maintenance.json". I'm guessing there's something wrong with your configuration. Could you post your config file?

Turnout.configure do |config|
  config.app_root = '.',
  config.named_maintenance_file_paths = {default: config.app_root.join('tmp', 'maintenance.yml').to_s},
  config.default_maintenance_page = Turnout::MaintenancePage::JSON,
  config.default_reason = "The API is temporarily down for maintenance.",
  config.default_response_code = 503
end

Oh yes. Once again I should be more careful about my README examples. Those commas shouldn't be there. Sorry about that. I've already updated the README.

This should work for you.

Turnout.configure do |config|
  config.default_maintenance_page = Turnout::MaintenancePage::JSON
  config.default_reason = "The API is temporarily down for maintenance."
end

The other settings will remain set to the default value if you don't change them.

Oh boy, good catch, I didn't even notice those. Silly me - thanks!