-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permission denied on lockfile when loading Rails Console #186
Comments
This is more a Ruby on Rails question than a "rufus-schedule" question.
You're in charge, you could take inspiration from http://stackoverflow.com/questions/4603704/how-can-i-detect-if-my-code-is-running-in-the-console-in-rails-3 and avoid scheduling when the initializer is run in console mode. I don't know what version of Ruby on Rails you're using but tell me if that StackOverflow Thanks in advance. |
@jmettraux thanks, your tip actually worked for me.
Thinking about it again, I guess you're right. The whole problem isn't the lockfile, but how I'm trying to do things with different permissions in this context. Thanks for you time, man 🚀 👯 |
You're welcome. What version of Ruby on Rails are you using? |
Oh, I'm sorry. Ruby 2.2.2, Rails 4.2.5. |
Thanks! |
In accordance with the option to avoid scheduling when running the rails console, is there a similar option to avoid scheduling in other scenarios where the rails environment reloads, such as when running migrations and other utilities using 'rake'. Or perhaps, a way to restrict the scheduling to rails server only. Thanks in advance. :) |
Hello, I had a look at http://stackoverflow.com/questions/2467208/how-can-i-tell-if-rails-code-is-being-run-via-rake-or-script-generate You could do something like: unless defined?(Rails::Console) || File.split($0).last == 'rake'
# not called from the rails console nor from a rake task, do schedule!
# scheduling...
end |
This works perfect. Thanks a lot for the quick response. :) |
Hi, I would like to add, if using bin/spring (https://stackoverflow.com/questions/39081940/determine-if-using-rails-console-or-server-when-using-spring): unless $PROGRAM_NAME.include?('spring') do
# code
end rails 4.2.6 When I use |
@aesyondu Thanks a lot! |
I've configured rufus-schedule to use some lockfile on production just like these:
And when I try to access the production console:
That means my app runs under a different user than my ssh user, but I think my scheduler shouldn't be loaded on console. Also, we use this filelock because we run Puma with a few threads and they've been starting the scheduler multiple times.
Is there any approach that I've been missing?
The text was updated successfully, but these errors were encountered: