Rails javan / when以root身份运行cron作业

时间:2016-07-23 07:29:09

标签: ruby-on-rails nginx passenger whenever

我在端口80上运行了Nginx + Passenger + Rails,这需要使用sudo启动nginx。现在,当我使用whenever时,它也以sudo身份运行。我该如何避免这种情况?

以下是log/cron/error.log的日志:

Ignoring bcrypt-3.1.10 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.10
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built.  Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring bigdecimal-1.2.7 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.2.7
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
/Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-11.2.2 in any of the sources (Bundler::GemNotFound)
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `map!'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from /Users/Passa/Documents/project/config/boot.rb:6:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from script/rails:5:in `<main>'

我尝试手动运行cron作业,每当生成:

/bin/bash -l -c 'cd /Users/Passa/Documents/project && script/rails runner -e development '\''Subscription.renew_user_bandwidth'\'' >> log/cron/cron.log 2>> log/cron/error.log'

但最终收到此错误:

Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring bigdecimal-1.2.7 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.2.7
/Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/spec_set.rb:95:in `block in materialize': Could not find libv8-3.16.14.15 in any of the sources (Bundler::GemNotFound)
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `map!'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `materialize'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in `specs'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in `specs_for'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/definition.rb:174:in `requested_specs'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/environment.rb:19:in `requested_specs'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/runtime.rb:14:in `setup'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler.rb:95:in `setup'
    from /Users/Passa/.rvm/gems/ruby-2.2.2@divshare-v2/gems/bundler-1.12.5/lib/bundler/setup.rb:19:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from /Users/Passa/Documents/project/config/boot.rb:6:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from script/rails:5:in `<main>'

0 个答案:

没有答案