Hosting Rails on local network - ruby-on-rails

I have been deploying my rails app to digitalocean on ubuntu OS and it's working fine. However, I would like to deploy my rails app on a local ubuntu network.
I have tried to setup rails on ubuntu and it's working fine and I am able to open network access with port 3000 by the same network to access via
$ rails server -b 0.0.0.0
This a bit slow from another local network computer to access. What is the better way where I can deploy rails app to my local server and only for same local network usage.

I have been doing the same thing on a Raspberry pi with several projects.
You can actually treat your local server like an external one. You can deploy on the local server using capistrano.
Just make sure that your app on your local server will be deployed as production, not development. I would also recommend NGINX and unicorn for performance and zero downtime deployment.

Related

How do you host a Ruby on Rails application on a home server?

As the title suggests, how can I host a Ruby on Rails application on a home server. I want to be able to develop on linux and then deploy on a server running linux. I know there's PaaS out there that help with deployment and host but for a specific job I need to be able to do it on a computer that will act as a server.
Your phrasing 'run a RoR project on a local computer for production' is a little strange.
If you just want to do development on your PC and have somewhere that will host your production app for free and you can push to from your PC (i.e. the way most development works) you want Heroku.
If you literally want to use your computer as the server for a production app you can use something like Ngrok, which creates a tunnel from the web to your localhost. However you would definitely not want to run most applications like this because if you ever shut down or even closed your computer the site would stop working. Additionally I would guess there's security concerns with using your computer as a server for a publicly accessible URL for any extended period, though I don't know that for sure.

How to access the local machine's serial port data using a Heroku application

I have an existing Ruby on Rails Heroku application. I want to get the serial port data from the COM 1 port in a Windows computer using this application, but since Heroku is a cloud-based platform running on a Linux server, I am unable to get serial port data from the local machine where the Heroku application is running. If I run the standalone Ruby code on that Windows machine, then it works fine and I am able to get my desired data.
I am getting the following error
Unable to open COM1
How do I solve this issue?
The part of code of my Rails application through which I am accessing serial port data is:
port_str = 'COM1' #may be different for you
baud_rate = 2400
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
i=sp.gets.chomp
puts i
This code is working fine if I run it on that local machine. 'serialport' gem is there on my gemfile.
Rails is a web server technology that runs on a web server. It builds HTML pages that get sent to a client computer and are rendered by the browser.
When you run Rails locally you are mimicing a real web server - localhost is basically running a web server on your local machine. That is why you can cheat and use Ruby code in your Rails app that locally can access the port of your local machine, but once you run your Rails app on a real web server (like in Heroku) you cannot do this, so you have the wrong tool for the job you are trying to do.
Not only that but since Rails is a web technology you have a web application that runs inside the browser and you cannot easily access the port on a client machine from a web browser. More information on that is in "How to read serial port data from JavaScript".
The ONLY reason your Ruby code is able to access the port is because it is not running in the browser when you run on localhost but it is running inside the web server that gets fired up on localhost, so when the app runs on a real web server that Ruby code will try to access the port of the server not any client machine.

run rails app with an ubuntu server with global ip

Currently, we are running our rails app, on AWS but we tried to move it to Heroku, which didn't work at all, now We are trying to run the app on Virtual Machine on hetzner. I can run the app on local server easily, my question is that, How can we run our rails app with a specific IP and then we can access that app anywhere in the world from that ip? is that possible to do so? We are using PUMA for server.
Yes, you can access to to your site with specific IP.
In description of hetzner Virtual Server says that server have 1 specific IP. So than you deployed and run you application y can access to app with 1.1.1.1:80 or another port.
If i understand you. Also what happened with heroku?

How to connect rails application(locally run on zeus) in another machine using IP?

I am using two rails applications, running both with rails s and zeus s -p3001 locally. When I am trying to run my application in another machine, the server started with webbrick is running fine on another system but couldnot run zeus. PLease help me out.
I just gave the url in browser 192.168.1.111:3000 (running). And
`192.168.1.111:3001` (server not found).
I tried zeus s -b 192.168.1.111:3001 but didn't help me.
The problem is, that the zeus bind to the local address (127.0.0.1) prohibiting connections from remove hosts. The proper solution would be to setup the reverse proxy using apache2 or nginx.
http://glasz.org/2013/10/25/reverse-proxy-a-rails-app.html
https://www.digitalocean.com/community/tutorials/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5
Alternatively you may also want to use firewall to redirect requests.
http://forum.slicehost.com/index.php?p=/discussion/2497/iptables-redirect-port-80-to-port-8080/p1
But a quick and dirty solution is to use SSH port forwarding like this:
Start zeus on remote machine on port 3000
On local machine
local-machine$ ssh -L 3001:localhost:3000 remote-machine
On local machine: Connect to localhost:3001 instead of to remote-machine:3000
http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html

Ruby on rails application in Windows Azure Virtual Machine

Hi i have created a ubuntu virtual machine in windows azure for deploying my rails application..
I have connected to my virtual machine through ssh and followed this procedure for deployment
<http://www.andrehonsberg.com/article/install-rvm-ubuntu-1204-linux-for-ruby-193>
<http://www.windowsazure.com/en-us/develop/ruby/tutorials/web-app-with-linux-vm/>
My deployment was completed successfully.
While starting my server by running rails s in my application i am able to see my application up and running in browser.
My issue is the server is stopped for every 10 minutes and again i have to connect to my server through ssh and need to give rails s..
i want a solution to run my application continously..
The problem is you haven't actually "deployed" anything. You just copied your rails app to a VM and ran rails s.
A production rails applications is not deployed in this fashion.
Consider using either nginx with unicorn or apache/nginx with passenger.

Resources