Skip to content
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

Support whenever environment_variable #13

Open
Val opened this issue Jun 28, 2018 · 12 comments
Open

Support whenever environment_variable #13

Val opened this issue Jun 28, 2018 · 12 comments

Comments

@Val
Copy link

Val commented Jun 28, 2018

:environment_variable make use of different :environment variable name, see Define your own job types for whenever

Val added a commit to Val/mina-whenever that referenced this issue Jun 28, 2018
@AnubixXx
Copy link

Is there a new version of mina-whenever gem? It's still reporting the problem with environment and invoke :'whenever:update' is throwing me command not found.

@Val
Copy link
Author

Val commented Sep 25, 2018

@AnubixXx : you can add this to your Gemfile until it's fixed.

gem 'mina-whenever', git: 'https://github.com/Val/mina-whenever.git', branch: :add_environment_variable_support, require: false

ping @d4be4st : could you please review this PR and eventually provide us a new release for this gem ?

@Val
Copy link
Author

Val commented Oct 8, 2018

@d4be4st , @mikong or @rstacruz , could you please review this PR ?

@texasecb
Copy link

@Val I have tried to use the suggested workaround above, but get the error:

mina aborted!
NoMethodError: undefined method `downcase' for nil:NilClass
/Users/<my_username>/.rvm/gems/ruby-2.4.2/bundler/gems/mina-whenever-78af0a48bc16/lib/mina/whenever/tasks.rb:2:in `block in <top (required)>'

I am assuming this is something I have done incorrectly in my project causing an issue in the line set :whenever_environment, -> { fetch(fetch(:environment_variable).downcase.to_sym) }.

Are you able to suggest how I may be able to resolve this please? I have also posted some additional information on StackOverflow here

Thanks for your time

@Val
Copy link
Author

Val commented Oct 14, 2018

@texasecb : did your read https://github.com/javan/whenever#define-your-own-job-types ? Did you set :environment_variable in your code ? Is the value of :environment_variable defined in your environment ?

Note default value of :environment_variable, if not set, is using previous default RAILS_ENV, see https://github.com/Val/mina-whenever/blob/add_environment_variable_support/lib/mina/whenever/tasks.rb#L1

@texasecb
Copy link

@Val I did read the articles previously, but to be honest I wasn't sure whether I should/shouldn't be doing anything in relation to this. I don't know that it should be anything other than RAILS_ENV, given it should default to this value I don't understand why downcase is acting on a nil value. I am pretty sure I have not defined the :environment variable anywhere

Thank you for replying so quickly. I am relatively new to Rails, so sorry if I am missing the point / misinterpreting

@texasecb
Copy link

texasecb commented Oct 14, 2018

Out of interest, I added the line set :environment_variable, 'RAILS_ENV' to deploy.rb (i.e. forcing it to be what sounds like the default value) - this resolves the issue I outlined above with the downcase function, but the command not found issue mentioned by @AnubixXx persists.

-----> Update crontab for <my_server_ip>_production
bash: line 156: bundle: command not found
! ERROR: Deploy failed.

I look forward to discovering what I am doing wrong

@AnubixXx
Copy link

I can run command: mina whenever:update from terminal and it works, but invoke whenever update in deploy.rb still throwing command not found.

@Val
Copy link
Author

Val commented Oct 17, 2018

@AnubixXx did you try

task :deploy do
  on :launch do
    invoke :'whenever:update'
  end
end

@SimonThordal
Copy link

The bash: line 156: bundle: command not found error seems to be fixed by changing to

task :deploy do
  on :launch => :remote_environment do
    invoke :'whenever:update'
  end
end

I am no expert, but I am assuming that :launch is opening a new shell and it needs to have rbenv loaded?

@tfwright
Copy link

tfwright commented Jul 31, 2019

@SimonThordal I tried your approach and for some reason mina then skipped the contents of the launch block entirely. This PR seemed to fix the error using the latest version of mina: #11

@raofeng
Copy link

raofeng commented Nov 20, 2020

https://github.com/raofeng/mina-whenever
Fixed problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants