biola / turnout

Turnout makes it easy to put Rack apps into maintenance mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

maintenance:end can't delete maintenance.yml

bryancorrell opened this issue · comments

I've been running into an issue on my production server where I put the site into maintenance mode every night to import new data, but when it finishes, the maintenance:end command fails to delete the maintenance.yml file because it's in use by java.exe

I'm running rails on a Windows Server VM using puma.

Is there any way to toggle the maintenance mode without using the yml file? Could I set a flag in active record or something of that nature?

Thanks!

That sounds strange. I don't know what Java would have to do with it at all. Are you running JRuby? Of course you could try just deleting the tmp/maintenance.yml file directly without calling the rake task. That's basically all it does.

I've honestly never tried anything Ruby on Windows. So I can't guarantee any of my code to work on Windows.

Yes, it's using JRuby and it is very odd. It always fails with an access denied error. Sometimes I can manually delete the file, other times I can't manually delete it without first stopping the server to unlock the file. When I try to delete it, it says that Java.exe is using the yml. I added a File.rm --force after the maintenance end to try and force delete the file (similar to deleting manually), but that still did not work.

Unfortunately, Windows is just a pain with file permissions and access, but that's my only option at he moment. What does your gem use to trigger the maintenance mode? Is there a way for me to trigger that directly without using the yml file at all?

Thanks for your help!

On Feb 20, 2016, at 8:45 PM, Adam Crownoble notifications@github.com wrote:

That sounds strange. I don't know what Java would have to do with it at all. Are you running JRuby? Of course you could try just deleting the tmp/maintenance.yml file directly without calling the rake task. That's basically all it does.

I've honestly never tried anything Ruby on Windows. So I can't guarantee any of my code to work on Windows.


Reply to this email directly or view it on GitHub.

That makes a bit more sense with JRuby anyway. I don't think I've ever tested it with JRuby but it would probably be a good idea.

I did a quick look through the code so make sure I wasn't forgetting to clone any file handles and I couldn't find anything.

The only way to trigger maintenance mode at the moment is with the file. I'd be open to triggering it with an environment variable but I don't think that there is an easy way to trigger that on the fly in most setups, so I don't think it makes a lot of sense. I had a request for a Redis backend to configure maintenance but i don't have the time to put into that now. But if i have a few spare cycles I'll look into JRuby.

So I had some time to look into this. I added JRuby to the .travis.yml file. No problems there. I also installed it locally created a new Rails app and installed turnout. No problems starting or stopping maintenance mode.

At this point I'm afraid I've gone as far as I'm willing to go solving this issue. My best guess would be that it's a Windows related issue and I just don't have the time or resources to support Windows. I'd highly recommend you consider running your app on Linux (maybe via Vagrant) or OS X.

If you have any more information about this issue, please let me know.