I am making a chatting application using Ruby on Rails with Faye gem.
The app works on localhost after I inserted "localhost:9292/faye.js" in the index.html and I run the following script on command line:
rackup faye.ru -s thin -E production
ruby faye.rb
However, the app doesn't work on Heroku even if I changed the source url to "http://myappname.herokuapp.com/faye.js" and makes these errors.
http://myappname.herokuapp.com/faye.js 404 (Not Found)
ReferenceError: Faye is not defined
I've tried these commands but no luck so far.
heroku bundle exec rackup faye.ru -s thin
heroku bundle exec ruby faye.rb
It would be great if you could figure this out.
I appreciate for your help in advance!
I changed the url to "http://myappname.herokuapp.com:9292/faye.js"
and run the following commands on the commandline
heroku run bundle exec rackup faye.ru
heroku run bundle exec ruby faye.rb
Now I am getting this error
http://myappname.herokuapp.com:9292/faye.js net::ERR_CONNECTION_REFUSED
I tested the app with "foreman start" on localhost and everything worked.
However, it still does not work on Heroku.
Related
I have web RoR, I ran assets:precomplie, and i got file
**/application-dfaaca6b25e0d101d80f81c5cb194f6d39d331886613c0a392283b01b9911cb0.css**
but my web was loaded another file
**application.self-a429e1a197d1ad3e5a775f50a60fd344db3ba490db151ab8c7494a78cba792a2.css**.
i don't know reason. Anybody, can help me? Thanks a lot
I got the same questions. then finally I find the answer:
when you process assets:precomplie, you must specify the env as you run rails, because in different enviroments, the assets version is not same!
when you run rails in development env as rails s, you should process as rake assets:precomplie or assets:precomplie RAILS_ENV=development
when you run rails in production env as rails s -e p, you should process as rake assets:precomplie RAILS_ENV=production
hope this helps!
Solution:
Deploy your application again
if still not solved
SSH into the system
delete the file your_app/manifest_backup
$ bundle exec rake assets:clear
$ bundle exec rake assets:precompile RAILS_ENV=production
restart the webserver ( for Nginx /etc/init.d/nginx restart or $ sudo service nginx restart )
if still not solved deploy your app again
For more info see my blog
https://cbabhusal.wordpress.com/2015/07/20/ruby-on-rails-production-staging-when-asset-path-is-outdated/
I want to monitor my app with upstart. I'm exporting using
rvmsudo foreman export upstart /etc/init -a <my_app_name> -u ubuntu -l /var/<my_app_name>/log
It finishes successfully, but when i do
sudo start <my_app_name>
I get the following output and nothing happens
<my_app_name> start/running
my procfile
web: rvmsudo passenger start -p80 -e production
worker: rvmsudo bundle exec rake jobs:work RAILS_ENV=production
Its really frustrating because i can run the web and worker commands on different terminals individually. So I tried to just do a foreman start and this fails with the following error
*** ERROR ***
Please install daemon_controller first:
/usr/local/rvm/gems/ruby-2.0.0-p594/wrappers/gem install daemon_controller
The frustrating bit is that daemon controller is installed and i can see it when i do gem list
Maybe my whole approach to this is wrong can someone please point me in the right direction?
Here's the line in passenger that returns that error, so it looks as though it really can't find daemon_controller as it's rescuing a LoadError. Try updating your web process to run via bundle exec also:
web: rvmsudo bundle exec passenger start -p80 -e production
I cant figure how to start Delayed Jobs on a dedicated Ubuntu server.
It works fine on my localhost but when I run on my server
sudo RAILS_ENV=production bin/delayed_job restart
I get
sudo: bin/delayed_job: command not found
On top of that, if I run the "rake jobs:work RAILS_ENV=production" command Im getting the following error:
PG::FeatureNotSupported: ERROR: SELECT FOR UPDATE/SHARE is not allowed in subqueries
Apparently theres an issue with my psql version.
Is there any way I can get the script to work? Any effective Capistrano recipes available? All ive found on the web are old recipes for Rails 3 and older versions of capistrano.
Thanks in advance.
EDIT:
I have already bundled install the daemons gem and generated "delayed_job:active_record" on my local machine, then proceded to cap deploy which bundle installed and migrated in the production server.
The bin/delayed_job file exists in the server yet it fails with command not found.
And add this to config/environment.rb:
ENV['RAILS_ENV'] ||= 'production'
Then at your production server:
RAILS_ENV=production rake db:migrate
RAILS_ENV=test production generate delayed_job:active_record && RAILS_ENV=production rake db:migrate
Now after you do that:
RAILS_ENV=production script/delayed_job start
As for Capistrano error you are facing, please try to add the command like:
run "cd #{current_path}; #{sudo} RACK_ENV=production bundle exec #{current_path}/bin/delayed_job start"
You must run this on target server:
bundle exec rails generate delayed_job
I am using the digital ocean ruby on rails image which has nginx and unicorn. I bundled my project bundle install and then did service unicorn restart but it doesnt seem to be loading. I had this issue a while ago and solved it using bundle exec ... but I cant remember the full command. I saw a few issue similar to this and tried bundle exec rake assets:precompile as well as editing the production.rb (Why "rails server -e production" makes it "No route matches "/" and stylesheet not loading?) file but it does not work. I am looking for the solution to do this through the command and not through code.
EDIT: bundle exec rake assets:precompile did somewhat work! The problem is that I created an extra css file called main.css which isnt importing, but everything else works!
Use RAILS_ENV=production rake assets:precompile. RAILS_ENV=production specifies the environment in which you run your rake tasks.
I have an issue with running the rails console at heroku (cedar-stack). Each of the following commands heroku run console, heroku run rails console, heroku run bundle exec rails console results in the following error-message:
Running bundle exec rails console attached to terminal... up, run.8155
Abort testing: Your Rails environment is running in production mode!
This error-message is a little bit confused. What kind of test tries heroku to start? I just want to fire up the console, which had worked fine 4 weeks ago.
For Cedar Stack and later:
heroku run rails console --app <app name>
Previous stacks could use this command:
heroku run console --app <app name>
If you have multiple environments (staging / production / etc) you need this command:
heroku run -a app-name console
If you only have a single environment and never setup staging or other environments you can just run:
heroku run console
https://github.com/nemrow/rails_app_cheatsheet/blob/master/heroku.rdoc
For some reason you need to explicitly define the console process in the Procfile:
# Procfile
web: script/rails server -p $PORT
console: script/rails console
This blog post has more details: http://platypus.belighted.com/blog/2013/01/21/ruby-2-rails-4-heroku/
I was with the same problem and I decided to do this and it worked
$ heroku run bash
$ cd bin
~/bin $ ruby rails console
You should just use heroku run console as others have answered.
Heroku only runs in one environment at a time, which is configured by the RAILS_ENV and RACK_ENV environments variables.
When you connect, the console will use the correct environment automatically.