pylons on production server fedora 8 - pylons

I'm interested in learning some python, and thought Pylons would be a good starting point (after spending 2 days trying to get django working -- to no avail).
I have an Amazon EC2 instance with Fedora 8 on it. It is a bare-bones install. I am halfway through my second day of trying to get it to work. I have mod_wsgi installed. I have Apache (though that's a later task to tackle). I have easy_install, paster is working fine; basically all of the pre-requisites mentioned throughout the Pylons docs.
I can't for the life of me get the thing to work. And I can't seem to find a coherent walkthough anywhere that lists all the steps necessary. There is tons of info out there, but it is all scattered. Wsgi this, python that. Google, google, google... "47 million results found for 'socket.error:(lol, 'Yous a goofs')".
So, this is my latest attempt:
apachectl -k stop
cd /home/
paster create -t pylons test
[blah blah.. ok]
cd test
nano development.ini
[hmm, last time I changed the host from 127.0.0.1 to my domain name or url, it threw an error like socket.error: (99, 'Cannot assign requested address')... I'll just leave it]
[open port 5000 on firewall]
paster serve development.ini
[firefox->url:5000]
Firefox can't establish a connection to the server
Doing these steps locally works as expected.
This is just a test to see if I can get it to work at all, which I can't. If I get it to work, then is the task of getting it to work with apache.
My madness is that I'd like to play around a little developing and deploying before diving into a full-fledged project. So far: self, I am dissapoint.

[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5000
If you leave it as 127.0.0.1, you'll only be able to surf the site from the ECS instance. By putting in the IP of your ECS instance, or 0.0.0.0 which will listen to all available IPs, it should work.
Unless you have something else listening on port 5000, it should work.
If you are using the hostname, and the hostname resolves to an IP address on your machine it should work. If you use a URL, paster won't be able to resolve the domain name properly. I'm guessing that when you used the domain name, it didn't properly resolve it which generated the error you received. 0.0.0.0 or the IP address in that case should fix it.
I'm not 100% sure whether you used a virtualenv for your pylons installation, but, it is generally a good idea since you don't need to alter the server's environment to install new libraries.
http://pylonshq.com/docs/en/1.0/gettingstarted/#installing

Related

Docker error localhost didn’t send any data

My development team and I have been having the hardest time getting our Ruby on Rails application to dockerize. All tutorials and answers out there seem to be years old and thus outdated.
After a few days of researching things and trying multiple techniques, we are finally finding answers. So, this post is to ask the most recent question and provide the answer we got.
In a new Ruby on Rails application running Ruby 2.7.0 and Rails 6.0.3.4, we would be able to run a rails server and get the standard Ruby screen at localhost:3000. But, after dockerizing the app and going to localhost:8000 as that is supposedly the default port for a docker image, we would get an error stating that the localhost didn't send any data.
This is the question, what is causing this to occur? We tried localhost and 127.0.0.1 and even the local machine's name that we got by running hostname in the terminal. None of these worked listening on port 3000 or port 8000.
The answer that we came up with for this problem is that the app was still saying that the information requests should be coming from port 3000 even though docker was looking at port 8000. So, we went into config/puma.rb and changed the code like this:
-port ENV.fetch("PORT") { 3000 }
+port ENV.fetch("PORT") { 8000 }
Basically, if you are having this same issue, look in the puma.rb file for the line that designates port 3000 and change it to port 8000. Once that happened, we were in business.
NOTE: The - and + signs in the code above are from the git repository showing that the first line was deleted and the second line added. Those symbols should not be in the actual code.
Good luck and happy codeing!

Unable to find the server's IP address even though an IP is defined

First of all, I need to warn you that I started to use Jelastic a few hours ago, so it might be a newbie question.
I'm using the "free trial" version of Jelastic, and made a few tests with them, where I tried a custom Docker image or a NodeJS environment.
I chose a MySQL image, a load balancer so that I have the SSL, and a NodeJS docker image.
It worked only once, the first time: I could reach the NodeJS image from outside, where a drawing game was available. After that, I only get the following error:
This website is unavailable
Unable to find the IP address of [the
auto-generated domain name thingy]
DNS_PROBE_FINISHED_NXDOMAIN
According to Jelastic, since I'm in free trial mode, I can't have more than one IP address, and it must be an IPV6. And according to this screenshot, it is enabled.
So... why can't I reach the server from anywhere?
Edit: here are a few screenshots (sorry for the time it took)
So after asking the question here yesterday, I changed the IP address from Nginx to NodeJS (just to test), and the error message got different, but not better:
It seems that somehow, even if I remove the ip from NodeJS to put it back to Nginx, I get the same error. No more DNS_PROBE_FINISHED_NXDOMAIN, can't obviously tell why.
Here is how look my IP address on both nodes:
Thank you in advance

How do I make my ruby on rails app respond to external requests (visible to the public on the internet)?

Problem:
My rails app (on my local machine) only responds to requests sent from the same machine to localhost, 127.0.0.1, or my internal ip address. When I try to hit it using my internet ip or from any other machine, inside or outside of my network, it just times out. I'm on Mac OS 10.9.1, ruby 1.9.3, rails 4.0.0.
I've done a lot of searching but all I can find is problems where people didn't forward their ports or bind the right ip.
Here are the areas I've investigated:
Ports -
I've tried several different ports. I configured my router to forward every port I tried but got the same result. I thought maybe there was a problem with the router so I built a simple server in Java and bound all the same ports I was binding with my rails app. Sure enough, when I hit the Java app using my internet ip it worked just fine so the router/firewall/port forwarding isn't the problem. Also, I run an apache server on port 80 and that has never had any problems. I turned apache off and tried port 80 for my rails app but that didn't fix the problem.
Rails Server -
I started with WEBrick and I thought that perhaps there was some setting inside that blocked external requests. I searched google extensively and found nothing on that matter. Just to be safe I installed Thin and got the exact same result I did with WEBrick. One interesting thing is that when the rails server is started, the external request takes a long time to time-out, but the server console displays no output at all. However if I try to send the same request w/out starting the server at all it fails immediately.
User Permissions -
I started the server with root (i'm starting to just shoot in the dark here) and it had no effect.
Environment -
I was starting in development environment originally because I'm developing but just for fun I tried starting in production and it also made no difference.
PLEASE HELP ME SMART PEOPLE
Update:
I installed the app on my Ubuntu machine and it doesn't have this problem! So that suggests the problem may have something to do with Mac OS.
SOLVED:
It turns out that in the System Preferences -> Security & Privacy -> Firewall in Mac OS, it was somehow set to block incoming connections to Ruby 1.9.3. I must have accidentally set that some time ago.
The problem is you are probably trying to request the page from your local machine (or any computer on your local network, behind your firewall) to your public IP expecting a result... not unless you setup routes through your firewall for this (and not usually available on a consumer level router... linksys, dlink, etc)
So forward port 80 if you are using something like pow, or 3000 for web bricks default port to your local machine
Then have someone outside your local lan request your external (public) IP
This may be related: Rails 3.1 on Ubuntu 11.10 under VirtualBox very slow
Your mention of slowness combined with the use of webrick makes me think you've got some reverse-DNS lookup awfulness going on. A quick first step is hacking /etc/hosts to bypass this lookup.
The situation I dealt with on Ubuntu was solved in the short-term by hacking /etc/hosts. You could do this quick hack in order to see if it is indeed just webrick's reverse-DNS lookup. Edit /etc/hosts and add a line for the external user's IP address, something like this:
156.123.48.55 TestPerson
Replace the IP address with the tester's IP address. Since you said you can get the external request to hit an Apache server on port 80, you can grab their IP address from the Apache access logs if necessary, otherwise just ask the person testing.
You could also try a different web server, such as unicorn, which may help out. Add "gem unicorn-rails" to your Gemfile, run bundle install, and then (according to their docs), rails server will just use unicorn directly.
With any local server, you'll need to correctly configure port forwarding on your firewall. Like said by CaptChrisD, tests must be done by an external IP/browser (if you own a server, ssh on it, then w3m to test).
I already had same symptom (server started => timeout, server stopped => fail) and the origin was an issue with firewall configuration. I think it is your problem.
With MacOS, Pow is really awesome: installation is easy, no configuration required (no /etc/hosts…). Moreover, they give you a hook for external access to your virtualhosts (but you still need port forwarding on your firewall).
Otherwise, there is other solutions like Forward to do it without firewall configuration (30-days free trial).
Hope this helps!

What is the safest way to test a local rails server?

I am not very experienced, but I have played around with rails a little in the past. When I did it was easy to test the app without actually exposing anything to the internet, since I could just point my browser to localhost. But this app will be getting input from a cellphone so I think it needs to be exposed. What I did so far was to push it to heroku and test there, but that does not seem like a good solution at all since every time I make a change i have push it. I am thinking I have to open a port on my router so and expose the server, which I think I can figure out how to do fairly quickly. Any suggestions on how to try to keep this as safe as possible? Or is there a better solution that I am missing?
The way you could test it if your server and your cell phone are on the same network is just find the local IP address on your machine running the server. You would then go into the browser of the cell phone and type the IP of your browser 'colon' the port the server is listening to (most likely 3000 if a rails server).
So for example if the servers IP was 192.168.0.1 it would be 192.168.0.1:3000
Since you are doing this on an app just put in 192.168.0.1 for the IP of the connection and 3000 for the port. Or if using a url 192.168.0.1:3000 (just like the browser)
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://192.168.0.1:3000");
A very simple way is to use Pow in combination with xip.io.
The former is a local webserver that will run any Rack application behind the scenes for you.
Installing is as simple as:
$ curl get.pow.cx | sh
and linking your app in:
$ ln -s <path-to-app> ~/.pow/myapp
Your app is now accessible at http://myapp.dev/ locally.
Assuming your computer's IP is 10.0.1.1 and your cell phone is on the same Wifi network, your app will be accessible on the phone from http://myapp.10.0.1.1.xip.io.
Caveat: you'll be getting Wifi performance, not cellular performance.

Cannot access http://localhost:3000

I am trying to learn Ruby on Rails, I have followed the instructions from this page to get rails installed on my PC.
I am also trying to follow this webcast to try and learn the language and framework. Everything is working so far, apart from the fact that I cannot access
http://localhost:3000
http://0.0.0.0:3000
http://127.0.0.1:3000, or
http://<actual IP address>:3000
locally. If I try the from another PC on my network then it works great. I have tried in Chrome, Firefox and IE7 but none work.
Has anyone else had this problem?
EDIT: Typical!! It's started working now. I have no idea why, I am typing the exact same address in to the address bar and it now works. But only if I use http://127.0.0.1:3000, localhost doesn't work. I do run IIS ASP.NET/ASP websites on this machine, and they work fine with localhost.
EDIT 2: If I trying pinging localhost it actually says
Reply from ::1: time<1ms
0.0.0.0 yields...
PING: transmit failed, error code 1214
only 127.0.0.1 seems to work. I did have IPv6 turned on, so I've disabled that and will try again tomorrow to see if a reboot helps.
I had this issue as well with Vagrant. The secret is to run
bin/rails server -b 0.0.0.0
What 0.0.0.0 means is to listen to all interfaces, not just on localhost. The alternative is to SSH into the vagrant machine with a SOCKS proxy.
ssh -C -D 8080 vagrant#localhost
Open up your Internet explorer proxy settings and set the SOCKS v5 proxy to port 8080.
In order to access http://localhost:3000 you need to run the local Rails server in a terminal window:
$ rails server
This is described in this section of the Rails Tutorial book.
Note: I am the presenter of the screencasts in question.
Can you telnet to the port? Try:
telnet localhost 3000
That should tell you if the ports unavailable at the TCP level, or whether something's going on at the HTTP level.
Ping might not work if ICMP is disabled, which could be completely unrelated to your issue.
Also, try looking in your hosts file for any redirections:
c:\Windows\System32\drivers\etc\hosts
One way is to do the simple
rails s
Another (more specifically) is
rails start localhost 0.0.0.0
or
rails start 0.0.0.0
another way is
rails s 0.0.0.0
all of these works
I had an epic issue with my System Path (Environmental Variable) not being set properly.
Simple copy paste job, unplugged the 1 week stalled Ruby installation.
Control Panel > System > Advanced tab > Environment Variables > System variables > Path... Edit...
Make sure it contains these paths (among others)...
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
I had your same identical problem. You have simply to run
$ rails server
from inside the folder of your application, not outside...so, if you have your application in
C:\Sites\myapp\blog
and blog is the folder where live your app, the command has to be prompted from here. Launching it from myapp folder won't work.
Are you possibly using a proxy but haven't listed localhost as proxy exception?
Have you tried disabling your firewall? They can cause pesky problems at times.

Resources