I am running rails 4.2 and have set up a rake task to send an email but get this error when I run the rake task:
** Invoke send_report_email (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute send_report_email
production
rake aborted!
OpenSSL::SSL::SSLError: hostname "localhost" does not match the server certificate
/usr/lib/ruby/2.2.0/openssl/ssl.rb:240:in `post_connection_check'
/usr/lib/ruby/2.2.0/net/smtp.rb:588:in `tlsconnect'
/usr/lib/ruby/2.2.0/net/smtp.rb:563:in `do_start'
/usr/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
/var/lib/gems/2.2.0/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
/var/lib/gems/2.2.0/gems/mail-2.6.3/lib/mail/message.rb:252:in `deliver!'
/var/lib/gems/2.2.0/gems/actionmailer-4.2.3/lib/action_mailer/message_delivery.rb:77:in `deliver_now!'
/var/lib/gems/2.2.0/gems/actionmailer-4.2.3/lib/action_mailer/message_delivery.rb:95:in `deliver!'
/path/to/app/lib/tasks/email_tasks.rake:4:in `block in <top (required)>'
/usr/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/bin/rake:33:in `<main>'
Tasks: TOP => send_report_email
The line production is just me having a put ENV["RAILS_ENV"] in the rake task to make sure it is set to production
my /config/enviroments/production.rb
config.action_mailer_default_url_options = {host: "my.host.com"}
config.action_mailer_smtp_settings = {
enable_starttls_auto: false,
domain: 'my.host.com',
address: "my.host.com",
openssl_verify_mode: 'none'
}
When I ran apt-get install postfix I configured it also to use my.host.com and not localhost. Where is rails getting that localhost value from?
Related
Deploying a Rails app to a new server, for the first time.
Running cap production deploy --trace gives me:
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
NoMethodError: undefined method `upcase' for nil:NilClass
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/configuration.rb:90:in `logger'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit/configuration.rb:51:in `output_verbosity='
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/configuration.rb:94:in `block in configure_backend'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sshkit-1.14.0/lib/sshkit.rb:11:in `configure'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/configuration.rb:92:in `configure_backend'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/setup.rb:32:in `block (2 levels) in <top (required)>'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/lib/capistrano/application.rb:14:in `run'
/Users/dfaulken-af/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capistrano-3.9.0/bin/cap:3:in `<top (required)>'
/Users/dfaulken-af/.rbenv/versions/2.4.1/bin/cap:22:in `load'
/Users/dfaulken-af/.rbenv/versions/2.4.1/bin/cap:22:in `<main>'
Tasks: TOP => production
Which seems entirely confined to gem code. Before I open an issue with them (sshkit?), has anyone seen this before?
I use Net::SSH::Config to get the SSH user from my SSH config file. I know that those settings are correct, as I'm able to use them to log into the server.
remote_user = Net::SSH::Config.for('50.198.83.200')[:user] || ENV['USER']
server '50.198.83.200', user: remote_user, roles: %w(app db web)
But I've tried setting the remote user with USER=the_user_name cap, etc. and still get the same error.
My log_level line was incompletely written as
set :log_level
With no second argument.
I have installed Redmine 2.6.1-stable, it works using apache2 and passenger.
I'm trying to receive emails using imap with this two rakes:
this one:
rake -f /opt/redmine-2.6.1/Rakefile --silent redmine:email:receive_imap RAILS_ENV="production" host=smtp.yandex.ru port=465 username=mail#yandex.ru password=pwd ssl=true project=desk folder=INBOX move_on_success=processed move_on_failure=failed no_permission_check=1 unknown_user=accept
And this one:
bundle exec rake redmine:email:receive_imap host='smtp.yandex.ru' username='mail#yandex.ru' password='pwd' port=465 ssl=true starttls=true allow_override=type,project project=desk
And this is log:
** Invoke redmine:email:receive_imap (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:email:receive_imap
rake aborted!
EOFError: end of file reached
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1150:in `get_tagged_response'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1210:in `block in send_command'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:1192:in `send_command'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/imap.rb:435:in `login'
/opt/redmine-2.6.1/lib/redmine/imap.rb:30:in `check'
/opt/redmine-2.6.1/lib/tasks/email.rake:128:in `block (4 levels) in <top (required)>'
/opt/redmine-2.6.1/app/models/mailer.rb:367:in `with_synched_deliveries'
/opt/redmine-2.6.1/lib/tasks/email.rake:127:in `block (3 levels) in <top (required)>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/admin/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/rake:23:in `load'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/rake:23:in `<main>'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/ruby_executable_hooks:15:in `eval'
/home/admin/.rvm/gems/ruby-2.1.5#rails3/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => redmine:email:receive_imap
I can't understand what's going on.. Why it does not work properly?
Log /opt/redmine-2.6.1/logs/production.log is empty about this operation.
I recently solved my similar problem with enabling debug on IMAP, so I could see what's happened. To do that;
vim /var/www/redmine/lib/redmine/imap.rb
and after require 'net/imap' add this line:
Net::IMAP.debug = true
It usually relates to the login credentials/method.
You are trying to receive IMAP email from an SMTP server. These are completely different protocols.
Likely you want server imap.yandex.ru, Port 993, with SSL (not starttls).
Settings for IMAP appear to be available at https://yandex.com/support/mail/mail-clients.xml
I have /config/initializers/redis.rb:
if Rails.env == "development"
$redis = Redis.new(:host => 'localhost', :port => 6379)
elsif Rails.env == "test"
$redis = Redis.new(:host => 'localhost', :port => 6379)
elsif Rails.env == "production"
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end
Obviously, when I run the app locally, REDISTOGO_URL is undefined.
Given this, how can I make rails server -e production work?
I need access to the production environment locally in order to run RAILS_ENV=production bundle exec rake assets:precompile.
Currently that yields the following error:
$ RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/bin/ruby /Users/steven/.rvm/gems/ruby-1.9.3-p286/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
bad URI(is not URI?):
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/uri/common.rb:176:in `split'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/uri/common.rb:211:in `parse'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/uri/common.rb:747:in `parse'
/Users/steven/Dropbox/testivate/config/initializers/resis.rb:6:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `block in load'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/engine.rb:587:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/engine.rb:587:in `block in <class:Engine>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/steven/Dropbox/testivate/config/environment.rb:6:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.9/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.9/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/steven/.rvm/rubies/ruby-1.9.3-p286/...]
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.9/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.9/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.9/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/Users/steven/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile
As bimsapi mentions in the comment an easy way would be to run
export REDISTOGO_URL='redis://localhost:6379'
at your command line, and maybe put it in your shell config for when you reboot?
Another way would be to just create it if it doesn't exist:
e.g/
ENV["REDISTOGO_URL"] ||= 'redis://localhost:6379' if Rails.env.production?
Also your conditional logic looks a bit out of place in your query above.
You may just want to drop the condtitions completely and do this instead?:
ENV["REDISTOGO_URL"] ||= 'redis://localhost:6379'
uri = URI.parse(ENV["REDISTOGO_URL"])
$redis = REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
HTH?
EDIT: Just seen this on configuring Rails Environment Variables - http://railsapps.github.com/rails-environment-variables.html
I'm doing a daily sending email task by using whenever gem.
I created a rake task in RAKEFILE name coffee. Here is my task's code:
task :coffee => :environment do
ReservationBooksNotify.notify.deliver
puts "hihi"
end
When I run this task in console
rake coffee, it worked!
But when I create a schedule in schedule.rb to automatically sending mail every minute, I get an error
hihi
rake aborted!
Connection refused - connect(2)
The error when I trace
rake coffee RAILS_ENV=production --trace
** Invoke coffee (first_time)
** Invoke environment (first_time)
** Invoke rails_admin:disable_initializer (first_time)
** Execute rails_admin:disable_initializer
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
** Execute environment
** Execute coffee
rake aborted!
Connection refused - connect(2)
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `initialize'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `open'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:540:in `tcp_socket'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:549:in `block in do_start'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:549:in `do_start'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.2.8/lib/action_mailer/base.rb:415:in `block in deliver_mail'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.2.8/lib/action_mailer/base.rb:413:in `deliver_mail'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
/home/duykhoa12t/Working/Bbookproject/Code/bbook/Rakefile:10:in `block in <top (required)>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/duykhoa12t/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/home/duykhoa12t/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => coffee
My schedule.rb (in /config)
set :output, "~/Working/whenever.log"
every 2.minutes do
rake 'coffee'
end
I think my mailer configure has no problem because It worked when I send mail in controller and in console. Please help me, thanks!
Finally, I don't know why, I try rake assets: precompile, then restart server, everything works!
I'm trying to create a rake task that restarts my heroku servier. I've found this post, which has helped immensely: http://railspikes.com/2010/2/13/rake-task-for-deploying-to-heroku.
I've cobbled together this rake task, but it's giving me an error. The rake abouts and I get the message:
uninitialized constant Heroku::Command::BaseWithApp.
This is my method.
desc 'restarts the server'
task restart_server: :environment do
require 'heroku'
require 'heroku/command'
user, pass = File.read(File.expand_path("~/.heroku/credentials.txt")).split("\n")
heroku = Heroku::Client.new(user, pass)
cmd = Heroku::Command::BaseWithApp.new([])
remotes = cmd.git_remotes(File.dirname(__FILE__) + "/../..")
remote, app = remotes.detect {|key, value| value == (ENV['APP'])}# || cmd.app)}
if remote.nil?
raise "Could not find a git remote for the '#{ENV['APP']}' app"
end
heroku.restart(ENV['APP'])
end
I'm not sure why it's rejecting Heroku::Command. The app is already live on Heroku, so I know it's Heroku compliant.
Any advice?
EDIT: Here's my stack trace.
** Invoke restart_server (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute restart_server
rake aborted!
uninitialized constant Heroku::Command::BaseWithApp
/Users/bendowney/Sites/ProblemChildApp/lib/tasks/scheduler.rake:51:in `block in <top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bendowney/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `eval'
/Users/bendowney/.rvm/gems/ruby-1.9.3-p194#ProblemChildApp/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => restart_server