I have been working on a rails app for months and then, all of a sudden the pumas server does not work on my laptop. I've tried different older branches (in case I changed something) I've uninstalled and reinstalled ruby. Nope. It DOES work if I do a fresh pull and load it on my desktop, so it seems to be something on my laptop? I am really lost.
Here's what I've done already:
Restarted the computer
reinstalled ruby
Tried puma
Tried rails s
Tried different branches to see if something I did yesterday somehow broke it
reinstalled gems
The error is:
The localhost page isn’t working
localhost didn’t send any data.
However, right before it was running this error, it ran a Request time out error, if that matters.
What I really don't understand is why it's only happening on one computer.
I am running Ruby 2.3.0 and rails 4.2.6
UPDATE
It DOES running rails server and not puma.
The problem is, I'm using foreman to start sidekiq with my server, and that's how I debug sidekiq queues. Strangely, sidekiq still works, but I can't access the localhost page.
This is my procfile:
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -c 2 -q default -q mailers
Again, I haven't changed anything with puma and rails s works fine.
Related
I'm working a Rails application ran into some problems with a 502 error when I tried to go to our staging site. This thread had the answer I needed by adding to puma.rb:
application_path = '/home/deploy/hotel-automata/shared'
bind "unix://#{application_path}/sockets/puma.socket"
I was also able to start the server in development by running foreman start -p 3000. The question I have is how does this not throw an error? The application_path I have definitely doesn't exist in my local computer and running bundle exec puma or bundle exec rails server threw an error on file not found. Is this something that's specific to foreman or am I missing something? I looked around for a while but couldn't find anything related to this.
Also, is this the best way to do this? I feel that using an exact path might not be the best way here but I'm not sure what else I should do. Any suggestions on this point would be much appreciated too.
Also, here's my Procfile:
web: bundle exec rails server
redis: redis-server
sidekiq: bundle exec sidekiq
I am trying to configure Sidekiq in a Rails 4.1.4 application that connects to an AWS Elasticache Node running Redis.
I set up my Redis server, and followed the directions in this AWS Guide:
http://docs.aws.amazon.com/opsworks/latest/userguide/other-services-redis-cluster.html
And my Redis server was running properly and my app server could connect properly.
I followed these directions to set up Sidekiq to run on the external worker:
https://github.com/mperham/sidekiq/wiki/Advanced-Options
Whenever I visited my app server at the /sidekiq url to view the Sidekiq panel, I kept getting the error on screen saying "Internal Server Error".
My Unicorn error logs do not contain any relevant information, so I am not sure how to get this working. AWS support did not have any answers either.
Any information would be greatly appreciated. Thanks!
This problem is normally seen when assets are not compiled or are not configured to be served from your environment. Start your app/sidekiq in production mode (or whatever environment this is referring to) after changing the production config to point to your local resources (redis+db) and see if the pages are able to load then.
RAILS_ENV=production bundle exec unicorn
RAILS_ENV=production bundle exec sidekiq -c config/sidekiq.yml
New to Rails and very new to Delayed Jobs.
Got one that's supposed to be triggered after 5 minutes. I finally got it to work so that if I run
rake jobs:work
in my terminal, the job starts up and works correctly. If I CTRL-C and exit that action in my terminal, the delayed job stops working correctly. This is one thing on my local server and another on Heroku, where I have to start up the delayed job using
heroku run rake jobs:work
I looked into the new Heroku toolbelt and downloaded the gem they suggest for worker maintenance, foreman, but when I run "foreman start", I get this error
ERROR: procfile does not exist
I don't know what a procfile is, I'm afraid of breaking things after spending pretty much a day debugging my delayed_jobs actions, and I want to do this right to make sure it works instead of figuring out some hacky fix that breaks down later -- so I figured I should ask this question, however obnoxiously vague it may be.
Should I be using foreman for this? Or workless? (Saw that in another SO question). Where's my procfile? Should I do anything with it?
Thanks,
Sasha
You should be using a procfile to set up your Heroku processes, this is the standard method that Heroku uses to define and control the processes.
If you haven't utilised a procfile to this point everything will probably still work as Heroku adds some default processes when you push a Rails app, including both the web and worker processes. The default worker process is set to delayed job.
Foreman was developed in order to set up your local machine to use the same approach but, unlike the Heroku service, Foreman actually requires a procfile to be present to control the services that are started when Foreman is started as it doesn't know how to setup defaults.
I would suggest creating a procfile, placed in the root directory of your project, to ensure that your processes are set up and operating in the same manner on your local machine as on Heroku. If you want to mimic what Heroku sets up automatically you add the following to the procfile depending on whether you are using the Thin web server (which Heroku recommends) or not.
With Thin in your gemfile:
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
worker: bundle exec rake jobs:work
Without a special web server (eg you are using webrick, the rails default):
web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
Once this file is in place you can run foreman on your local machine and it will start your web server and delayed_job workers automatically.
Running through this process will only impact starting delayed_job on the local machine. As you are running the exact same command bundle exec rake jobs:work as you are currently using there should be no impact on your dj actions in either locally or on Heroku. Obviously some testing is required to make suer this is actually the case.
Workless is designed to scale workers on Heroku so that you don't have to pay for them when there is no work available. It has no bearing on the procfile or defining how to actually start a dj worker process.
as far as I know, there are 2 version of delayed_job:
original(tobi's) https://github.com/tobi/delayed_job
collectiveidea's fork: https://github.com/collectiveidea/delayed_job
when using the collectiveidea version, you should start it as below:
# Runs two workers in separate processes.
$ RAILS_ENV=production script/delayed_job -n 2 start
I am not familiar with delayed_job on Heroku, please follow its instructions.
Here's what my Procfile looks like:
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
worker: bundle exec rake jobs:work
I intend to add a worker process because I wish to run some background jobs. I'm following these instructions
This is what I noticed:
No problems encountered if the worker is started separately.
When I keep the second line in the Procfile and don't not change anything else, the rails server serves a couple of requests and hangs after that
As mentioned here , I've added STDOUT.sync = true to config/environments/development.rb and verified the same in the rails console. Did not work.
Tailed log/development.log and compared it against the stuff that foreman outputted to the shell and noticed that both matched for a couple of requests and then foreman stopped printing out stuff to the shell - the next request would then hang
I updated foreman using foreman.pkg as mentioned here and verified the same with [6]
It was mentioned here that this might be caused due to a stray debug statement. I'm not using the debugger and I do not have the pry gem or the ruby-debug gem in my Gemfile.lock
I believe the symptoms are similar to this related unanswered question
Please help!
[6]:
which foreman
/usr/bin/foreman
ls -lah /usr/bin/foreman # checked the updated date
Tracked and resolved here:
https://github.com/ddollar/foreman/issues/244
TL;DR: Install the gem, don't use foreman.pkg
I'll add than if you're using Heroku, the foreman version included with the heroku toolbelt has the same issue.
Use the one you can get with gem install foreman instead.
I'm running Teambox (a Ruby on Rails app) and have the server running with:
script/server -e production
Knowing absolutely nothing about Ruby on Rails I just wandered how I could restart the server to get it to update changes I've made to the config?
If you ran it with that command line it's probably running actively in the console, just CTRL+C.
If you ran it daemonize you will need to find the process and kill it.