Rails 4 Not Running Server - ruby

When running the command
rails server
instead of the server running, I am getting the following output:
Why is the server not running?

It looks like you're not executing rails server inside a rails app directory.
Use rails new app_name and change directory into that app and run rails server again.

Related

Sidekiq on production server gives error on runing

We are using Amazon AWS Ubuntu machine for our server.
Rails 4.2.7 and Ruby 2.3
I have installed redis with these instructions (Redis)
and installed sidekiq with Sidekiq
I started redis, then starting sidekiq with just bundle exec sidekiq it give me error as running the jobs
FATAL: password authentication failed for user "ubuntu"
Not sure why this error. Any suggestions ?
Closing this thread as it has been fixed.
Changed the permissions for Redis from root level to user level.
And running sidekiq in production mode.

RubyMine - Debug Rails App - Unicorn Server

i am trying to debug rails app - unicorn server.
I've tried following:
1) I tried to start the server on localhost (externally, not with RubyMine) and set some break points. I can see my server when trying to "attach to process". It can attach to process but when i call some REST WebService it won't stop on this method in controller.
2) I tried to run the server from Debugger in RubyMine, the server starts, but when i call some REST WebService it won't stop on this method in controller.
How to debug the Rails App on Mac OS (localhost, unicorn)?
The Rails App ist only API. I want to debug my api calls.
Problem solved:
- i was using pow and it was redirecting to some url and not directly to localhost:3000. Once i converted the requests to use localhost:3000 instead of pow URL xxx.something.test debugger fired up.
I don't have rubymine but this worked for me:
install "pry": https://github.com/pry/pry
start unicorn on your local env:
bundle exec unicorn -c config/unicorn.rb
make sure you're listening to a valid port (in your confic/unicorn.rb):
listen 3000
add
binding.pry
in your code wherever you want a breakpoint
go to:
0.0.0.0:3000

Can a Rails 5 application with ActionCable be deployed on Windows?

I have a Rails 5 application which I was planning to deploy on Linux, but because we needed some access very specific Windows-only software, I need to deploy it on Windows Server 2012 R2. My software stack (or mix) was supposed to be Nginx/Puma/Rails/PostgreSQL/Redis. Everything installs for me on Windows except Puma, and the Rails documentation says that I need Puma for ActionCable.
How do I get Puma to run on Windows? I have seen and tried snippets of things to try, and I have also seen and tried snippets on what not to do, such as running in daemon mode because fork() is not supported. Does anybody have a repeatable set of instructions on how to get Puma to work on Windows with a Rails application?
Or, if Puma a non-starter for Windows, is there a repeatable alternative for deploying a Rails 5 application with ActionCable to a Windows Server host (e.g. Windows 2012 R2)?
According to the readme file from the github page, following things to keep in mind:
daemon mode is not supported. so comment out/remove the following, if there is such line.
daemonize false
Workers do not work in Windows since it does not support processes. We want the workers to be "0". So comment out following lines:
workers 2 # The default is "0"
preload_app!
server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to ruby.
Do not use unix socket, instead bind the server to "tcp://". So comment out any line that looks like following:
bind 'unix:///var/run/puma.sock'
bind 'unix:///var/run/puma.sock?umask=0111'
Instead use following:
bind "tcp://127.0.0.1:4001"
# You don't have to if you don't need to specify a port
# since the default is "tcp://0.0.0.0:9292"
If you see any http parse error (malformed http request) after starting rails server, try this answer. If it doesn't work, then comment out this line from config/environments/production.rb or config/environments/production.rb (depending on which environment you want to run Puma)
config.force_ssl = true
Here is what the puma.rb file might look like:
worker 0 # Not necessary. The default is "0"
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
bind "tcp://127.0.0.1:4001" # Not necessary. Default is "tcp://0.0.0.0:9292"
environment ENV.fetch("RAILS_ENV") { "development" }
plugin :tmp_restart
Finally run bundle exec puma -C config\puma.rb and it should work.

Why Rails Server not working because of SSL?

I'm working on an app currently and I attempted to replace my webserver WEBrick with puma. The application is currently deployed with Heroku. Also, while doing this I wanted to be able to run my rails s with production. To my understanding, I would need to set the SECRET_KEY_BASE key in my secret.yaml file. I did this while also setting up a SECRET_TOKEN in heroku. To make a long story short, I actually reverted back to WEBrick webserver. But now, when I run rails s production or development, I get the following:
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-04-27 13:40:57] INFO WEBrick 1.3.1
[2016-04-27 13:40:57] INFO ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2016-04-27 13:40:57] INFO WEBrick::HTTPServer#start: pid=24061 port=3000
When trying to load the page at https://localhost:3000/ I get the following errors in terminal:
[2016-04-27 13:41:09] ERROR bad URI `]n?Q2}N?<\x01H\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad URI `dU?\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03}??4??CN??\x02\x04?4?\x17??\ea??u%?\x06?yڔ\x13?\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03????3?W\x14kt??0M\x1A#U?"u?Ä??qj?]}??\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03?f\x1E?V?4?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03??C?ݔ\x01\r?OS#?S??Ej?\\\x15\r\x17k\x0Ep?\x1C?"?F\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
And the following in my DOM:
This site can’t provide a secure connection
localhost sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
So obviously I did something when setting up the SECRET_TOKEN/SECRET_KEY_BASE because before it was working and now not a single project of mine can run the rails server. I understand that this is dealing with SSL, but I am unsure where to begin or how to fix this. I have tried and read a lot and have yet to have some luck.
SIDE NOTE: I have created a brand new rails project from scratch and simply tried to run rails s. I have had the same issue. As I commented below, I was having the same issue when trying to run puma as my webserver. I now cannot run a local server on ANY project of mine. This leads me to believe that I have messed something up that applies to my system.
Thank you for any time taken/spent to help me.
FIXED:
Okay, so for whatever reason(something I did I'm sure), when I attempted to visit localhost:3000 it would take me to -> https://localhost:3000 which, as you stated, could not be handled by WEBrick unless configured to do so. My address bar continued to force HTTPS, even if I tried visiting http://localhost:3000. After I cleared my cookies/history...everything is working. I appreciate your help.

Environment variables with Rackup, Thin, and Oracle

I've written a server using Sinatra that accesses an Oracle database using ActiveRecord (though this is not a Rails app). I wrote it in Sinatra's "classic" style and previously started the server like this:
bundle exec ruby bin/server.rb
I also used require 'thin' and Thin was magically used as the HTTP server. However, I needed to change Thin's default timeout, so I transitioned to a rackup config.ru file. I now start the server like this:
bundle exec thin -C config/thin.yml -R config/config.ru start
However, since doing this I can't connect to the Oracle database with the server. I'm using a service name and the TNS_ADMIN environment variable is set correctly and I can connect with sqlplus or even the same server if not launched using Thin. Launching with Thin, when I try to start the connection I get OCIError - ORA-12154: TNS:could not resolve the connect identifier specified.
What is the right way to set environment variables for servers launched with Thin? The solution here doesn't work because I can't give ruby-oci8 the information, it automatically reads them from the environment.

Resources