I'm trying to deploy an application to Heroku after upgrading to Rails 3.1 with the asset pipeline. I ran into the common issue mentioned on Heroku's troubleshooting page when receiving the error:
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port xxxx?
I took the suggestions on the page and added the following to my config/application.rb file (after also trying to add it to the individual [environment].rb files to no effect)
config.assets.initialize_on_precompile = false
I've modified my database.yml file to point my production environment to a non-existant database, but when running the assets:precompile task locally, I get the following:
> RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
FATAL: database "my_nonexistant_database" does not exist
Tasks: TOP => environment
(See full trace by running task with --trace)
I'm trying to figure out what part of my application is trying to initialize the database so that I can fix it, but I've run out of ideas for getting more debugging information than this.
Anyone have any tips for either getting more information about where my app is trying to init the DB, or for fixing the underlying problem?
You should try the new labs feature http://devcenter.heroku.com/articles/labs-user-env-compile which will make variables available at slug compile time.
Related
I'm having a problem running the oink gem on my app in Heroku. I've included it in my gemfile and gemfile.lock, uploaded those, and it installs. It even creates the oink.log (which I have no way of viewing, unfortunately). When I run
heroku run bundle exec oink --threshold=0 log/* --app my_app
I get
Running bundle exec oink --threshold=0
log/delayed_job.log log/development.log log/oink.log log/production.log log/test.log attached to terminal... up, run.3
/app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:88:in get_file_listing':
Could not find "log/delayed_job.log" (RuntimeError)
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:ineach'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:in get_file_listing'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:59:inprocess'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/oink:4
from /app/.bundle/gems/ruby/1.8/bin/oink:19:in 'load'
from /app/.bundle/gems/ruby/1.8/bin/oink:19
I've tried running each of the individual files, too, and get the same result. This command runs fine on my local machine.
In my production.rb file, I have
config.logger = Hodel3000CompliantLogger.new(config.paths.log.first)
config.middleware.use( Oink::Middleware )
as configuration.
Can you enlighten me on what I'm doing wrong here? My understanding is that the logs are read only, but I don't know if that means they're only accessible through the heroku logs command. If there's a way I can see the oink.log file, too--knowing how to do that is also appreciated, or knowing how to see it in the actual Heroku log using heroku logs.
UPDATE: The configuration for oink shown above allows the commands to be run successfully on my localhost.
Thanks!
-Andrew
I'm following the instructions here: https://devcenter.heroku.com/articles/redistogo to deploy redis on Heroku. I'm however running into some issues while manually precompiling my assets on localhost using:
RAILS_ENV=production bundle exec rake assets:precompile
before pushing it out to heroku. The ENV["REDISTOGO_URL"] config variable isn't set when I'm doing the production mode precompile on localhost so I get an URI error when URI.parse is called.
How do I get around this error? I don't want to hardcode the URI in my production.rb since Heroku sets this when starting the redis server. I'm quite new to this whole asset pipeline / deployment processes so any tip would be appreciated.
In application.rb, I set the following to prevent initialization prior to Redis starting up:
config.assets.initialize_on_precompile = false
Hi i am using the gem https://github.com/PRX/apn_on_rails.git and followed the instructions to send push notifications for my iOS app.I created notifications like:
device = APN::Device.create(:token => "XXXX XXXX XXXXX XXXX XXXX .... XXXX")
notification = APN::Notification.new
notification.device = device
notification.badge = 5
notification.sound = true
notification.alert = "My first push"
notification.save
And run the rake command in my local server:
rake apn:notifications:deliver
to send the notifications.Everything went well but my mobile received nothing still. I checked the apn_notifications table and found the sent_at was still nil after running rake command.I saved several notifications in database but none of them were delivered (all the sent_at stayed nil).Well i got something as
$ rake apn:notifications:deliver --trace
** Invoke apn:notifications:deliver (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute apn:notifications:deliver
I included
begin
require 'apn_on_rails_tasks'
rescue MissingSourceFile => e
puts e.message
end
in my Rakefile.Is there anything I missed so that the notifications can't be delivered?
I had the same behaviour, and for me, it turns out that I have used the incorrect PEM certificate. And once I converted the certificate from .P12 to .PEM properly, and put it in /config folder, it worked.
One way to debug it, is that instead of waiting to use RAKE to push the delivery to Apple server, you can try calling
APN::App.send_notifications
immediately after the notification.save
within your ruby/rails controller.
from the log when running it, I saw that Apple is rejecting my connection, hence I knew my cert was incorrect.
I'm deploying to servers with capistrano and doing a bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile as the last step. Problem is when it gets to this point FROM cap deploy, i get the following error:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90:in `block in materialize': Could not find Platform-0.4.0 in any of the sources (Bundler::GemNotFound)
Platform-0.4.0 IS in fact on the server. And when i go into the server and run this exact command, all works great.
Couple of facts about my server: its using RVM, but that doesn't seem to be an issue with cap as the stack trace above would suggest. The other fact of interest is that this server was first created with a custom script I wrote that downloads an archived version of the git repo and then manually runs what cap does on a deploy. The reason I'm doing this, if anyone asks, is for automation with AWS AutoScaling. If i do a normal deploy:setup (not using my AWS script), it works fine with deployments. But the gem list is the same, and the site works all the same either way. Its just something with the cap deploy
Any thoughts?
I figured out what I was doing wrong. on my custom AMI scripts, i was naming the initial release folder 'first' when it should be a timestamp the way capistrano normally names it. That screwed things up on subsequent deployments.
I am working my way through the RhoMobile tutorial http://docs.rhomobile.com/rhoconnect/command-line#generate-an-application and I at the point of entering
rake redis:install
I get the following error.
WARNING: using the built-in Timeout class which is known to have issues when use
d for opening connections. Install the SystemTimer gem if you want to make sure
the Redis client will not hang.
See http://redis.io/ for information about redis.
Installing redis to C:\RhoStudio\redis-2.4.0;C:\dropbox\code\InstantRhodes\redis
-1.2.6-windows.
rake aborted!
Zip end of central directory signature not found
Tasks: TOP => redis:install => redis:download
(See full trace by running task with --trace)
D:\Dropbox\code\rhodes-apps\storeserver>
I am working on a Whindows machine, primarily using RhoStudio.
It ended up being an environmental variables issue. Also, it seems the main support forum for Rhodes is the Google Group. Question answered here:
https://groups.google.com/d/topic/rhomobile/b-Adx2FDMT8/discussion
If you are using Rhostudio in windows then redis is automatically installed with Rhostudio.
So no need of installing it again.