Can't change server address with private_pub on rails 4 - ruby-on-rails

I have been using private pub on my local machine and it works fine but now that I'm trying my rails app on a private vps it's a different story. I have been trying to change the server string in the private_pub.yml to the ip of my vps, but I realised that nothing changes no matter what I do. It always keeps serving localhost:9292.
So I tried the same thing on my local machine, I changed the server string to "http://192.168.1.11:9292/faye" in the development and production environments as you can see here (I changed the server adress in both environment just to be sure...) :
### config/private_pub.yml
development:
server: "http://192.168.1.11:9292/faye"
secret_token: "secret"
production:
server: "http://192.168.1.11:9292/faye"
secret_token: "thisisasecrettokenmyfriend"
And when I run bundle exec rackup private_pub.ru -s thin -E production I always get:
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:9292, CTRL+C to stop
So why does it not read the server address in the private_pub.yml file ? Is private_pub too deprecated ?
Any answer, suggestion, tip will be greatly appreciated :)

try
bundle exec rackup private_pub.ru -o 0.0.0.0 -s thin -E production
so the server will listen everything

Related

Rails: use Capistrano to deploy, how to check log when error happens?

I am deploying a rails add using Capistrano on remote Ubuntu 14.04 server.
Finally when I restart nginx, web page shows an error
We're sorry, but something went wrong.
I hope to know what cause the error, what command can I use to see log from remote server
try
bundle exec tail -f log/production.log
if no error is seen there then first check your nginx logs at
tail -f /var/log/nginx/access.log
or
tail -f /var/log/nginx/error.log
if you see some request logging there then that means request is coming to server and its not passing to puma server.
There can be two reasons about why request is not being passed to puma, either your address of puma process is not correct in nginx file or puma server is not running or there was some error and puma was shutdown when request reached it.
to see puma process use this command
ps aux | grep puma
it should print one line out of many lines
app 22528 0.1 0.5 296532 23912 ? Ssl 16:42 0:00 puma 2.11.1 (tcp://0.0.0.0:8080) [20180110213633]
now using this information I can map address like this in nginx
upstream app {
# Path to Puma SOCK file, as defined previously
server 0.0.0.0:8080;
}
here I bind the puma local ip with port to nginx process.
Make sure your puma.rb binds properly to puma.sock file as for one of my project I am doing like this in config/puma.rb
bind "unix:///Users/Apple/RAILS_PROJECTS/tracker/tmp/sockets/puma.sock"

"rails s" boots thin but cant access via localhost

I am having difficulty getting rails up and running. I have gotten as far as booting it with the command
rails s
This results in the following output:
=> Booting Thin
=> Rails 3.2.22.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
installing dummy notifier
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
When I run localhost:3000
I had the line:
config.vm.network "forwarded_port", guest: 80, host: 8080
in my vagrantfile but tried to change this and ran
vagrant provision
but to no avail. Are there any ways for me to test why I cannot access the project. Any guidance would be appreciated. Thanks!
UPDATE:
Having run the command:
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:seed
I received a few errors regarding deprecation and "ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation 'capabilities' does not exist"
Would this have anything to do with it not loading correctly?
In your vagrantfile, try to use:
config.vm.network "forwarded_port", guest: 3000, host: 3000
You don't need to run vagrant provision to change port forwarding, you can just restart the box with vagrant reload.
Rails defaults to only binding to localhost, and won't allow connections from other hosts (even a browser on your port-forwarded host). Try starting the rails server binding on all addresses like this:
rails s -b 0

What is localhost and where is it defined?

I just changed from thin to puma at the recommendation of Heroku. When I start my rails app using the puma server it responds:
=> Booting Puma
=> Rails 4.2.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.11.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
However if I go to http://0.0.0.0:3000 in the browser, which was my old localhost with the thin server, it does not respond. However, if I open http://localhost:3000, then it works. It appears that the definition of localhost has changed.
So, what is localhost? In particular, what sort of object is it, how is it defined, how do I see the actual ip address, and why does puma change it?
If you're trying to get Rails to bind to a different ip, the way to do that is with the -b option. To bind it to 0.0.0.0 instead of the Rails-default localhost you'd want to run something along the lines of rails s -b 0.0.0.0
Note: To be explicit, it may not be a bad idea to throw the -p 3000 option in there too (sets the port), even though that default is not likely to change. More info on the available options can be found by running rails s -h as well.
Localhost is the IPv4 loopback IP address 127.0.0.1. It is used instead of the hostname of a computer. Localhost can sometimes mean this computer.
For example, directing a web browser installed on a system running an HTTP server to http://localhost will display the home page of the local website.
Here's an interesting Wikipedia article
https://en.wikipedia.org/wiki/Localhost

Production mode is not running on port 80 (Rails)

I don't understand why it's not running on port 80 instead of port 3000 when I run the command RAILS_ENV=production rails s on the same line. I want it to run in production mode but it's not running on the correct port. Anyone know why? I'm trying to use Rubber but I haven't ran any commands for it only just changed some of the files like it says in this tutorial.
root#ip-000-00-00-000:/home/ubuntu/Git/# RAILS_ENV=production rails s
=> Booting Thin
=> Rails 3.2.11 application starting in production on \http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
\>> Thin web server (v1.5.1 codename Straight Razor)
\>> Maximum connections set to 1024
\>> Listening on 0.0.0.0:3000, CTRL+C to stop
^C>> Stopping ...
Exiting
webrick runs on port 3000 by default(even in production mode). Pass the port number explicitly if you want to run on a different port.

How to show application requests on terminal window while using Thin and Rails 3.0

I started using Thin instead of WEBrick in development (Rails version 3.0.9)
With WEBbrick, I would see all the requests listed (and calls to the database) in the terminal window while the server was running.
How do I get that with thin? When I do thin start the only output I see is:
>> Using rack adapter
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Try thin start -V.
https://github.com/macournoyer/thin/blob/master/lib/thin/runner.rb#L134
opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)")
try rails server thin -b 0.0.0.0 -p 3000 -e development
or run it with bundle
bundle exec rails server thin -b 0.0.0.0 -p 3000 -e development

Resources