Running Rails Console Gets Killed - ruby-on-rails

When i run on my production servers the command:
bundle exec rails c production
After few seconds i get "Killed", the server has 32GB RAM and have no lack of memory.
I use Ruby 2.1.6 with Rails 4.2.9 On CentOS 6.5.
I tried add SWAP file it doesn't worked.

Related

AWS elastic beanstalk is not getting the environment variables

I'm trying to run a Rails 6 app on AWS Elastic Beanstalk, but I get from puma log the following (repeats every few seconds)
[21776] + Gemfile in context: /var/app/current/Gemfile
[21776] Early termination of worker
The version numbers:
Rails 6.0.3.3
puma 4.3.5
ElasticBeanstalk Ruby 2.7 running on 64bit Amazon Linux 2/3.1.1
ruby 2.7.1p83
The server is unresponsive from outside the instance, and there's nothing on log/production.log.
Running on a dev machine on production mode there's no errors, and the database is reachable (no migration failure).
Running on the AWS instance the command bundle exec puma -p 3000 -e production I get
Puma starting in single mode...
Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Min threads: 5, max threads: 5
Environment: production
Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
so there's no obvious error that may cause the worker to halt.
How can I find out what's causing the workers to fail?
Edit 1:
I ran Rails console on the instance and found that the environment variables are missing - e.g. the production database user/pass/host. Once I hardcoded them I could connect to the database.
I suspect the absence of other environment variables is making the app crash.
A user on AWS forum had the answer.
Setting in my Gemfile
gem "nio4r", "= 2.5.2"
fixed the issue.

The localhost page isn’t working ruby rails puma osx

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.

How to run 'resque:work' rake task from rails application?

Having followed the rails-cast (http://railscasts.com/episodes/271-resque?view=comments), I was able to setup my rails application similarly with worker and rake tasks.
However, as specified in the rails-cast, once I start my rails server, I have to issue the following command in a separate terminal window:
TERM_CHILD=1 QUEUES=* rake resque:work
This gets me up-and-running and I have no issues. However, instead of firing off a rake command on terminal (or writing a startup shell script), I would like to issue this terminal command (TERM_CHILD=1 QUEUES=* rake resque:work) from Rails itself when the application starts up so its available during the duration of the application's uptime on the server.
I am in the process of learning Rails framework so I would greatly appreciate if you can give me some help and let me know how/where to place any code snippet you may provide me with.
Thank you very much in advance.
Here are my environment specs:
I am using jruby (jruby 1.7.16.1 (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_72-b14 +jit [linux-amd64])
Rails version 4.1.8
I am developing on LINUX ubuntu 14.04
I will be deploying this application to Windows 2008 server on a Tomcat server as a WAR package
I am using PostgreSQL as my database.
That approach would make it difficult to turn off your resque workers. I recommend using a common gem called foreman to handle this. I'll let you look a the documentation, but your Procfile would look something like:
web: rails s -p $PORT
resque: TERM_CHILD=1 QUEUES=* rake resque:work
And you would be able to start both rails and resque by just running the foreman command in console. That will also allow you to exit out of both easily.
Updated per OP's message:
require 'resque/tasks'
ENV['TERM_CHILD'] = 1
ENV['QUEUES'] = '*'
Thread.new { Rake::Task["resque:work"] }
The Thread.new is there because it would otherwise cause the rest of the app to never load.

deployed to heroku, can't see project in development

I built a rails app and successfully deployed it to heroku
Now I would like to access the development version to make changes on my local machine
When I rails s I get the error:
A server is already running. Check /home/username/myApp/tmp/pids/server.pid
That file has one line that reads 2673
What can I do to start the rails server while the app is hosted on heroku?
rm /home/username/myApp/tmp/pids/server.pid
Then
rails s
If it is not working
If you want to kill rails server process on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID
Then
rails s
Hope you will be able to run rails server again in your local m/c

Restarting Teambox Server

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.

Resources