Pregunta

Please forgive my ignorance. I don't know anything about the play framework, or the MVC design pattern so please bear with me.

I need to write a shell script to check if our service is still up. I had planned to use curl to get the http response code and check if it's a 200 or 404. We are using the play framework and designing the site using the MVC design pattern. I know nothing about these 2 things so it might be adding to my confusion.

Anyway, the website is up because I checked in Chrome and FF and it's up and working. I ran this curl command, which should give me a 200:

curl -I http://oursite.com:8080
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Content-Length: 1900

As a return code in the header, I get a 404. I don't know much about web technology but I read up on 404 status codes from wikipedia and it seems like it's looking for a index.html page (or whatever the requested page is). I found a /dir/of/play/deployment/public directory on our server. I blindly created an index.html in it but it didn't help. I still got a 404 when I was expecting a 200.

I also tried using wget. wget gives me a 200, but it downloads the contents of the main page to my local acct to a file called index.html. I ran

wget http://oursite.com:8080
--2014-01-29 19:42:42--  http://oursite.com:8080/
Resolving oursite.com... 10.64.8.76
Connecting to oursite.com|10.64.8.76|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27181 (27K) [text/html]
Saving to: “index.html”

I also ran another wget command but this one gave me a 404. I used the spider option to not download the file locally.

wget --spider http://oursite.com:8080
Spider mode enabled. Check if remote file exists.
--2014-01-29 19:42:42--  http://oursite.com:8080/
Resolving oursite.com... 10.64.8.76
Connecting to oursite.com|10.64.8.76|:8080... connected.
HTTP request sent, awaiting response... 404 Not Found
Remote file does not exist -- broken link!!!

The output of the last command said there's a remote file that it's looking for but can't find. However, clearly the site was sending some content when it wasn't in spider mode thanks to the creation/existence of the index.html pg in my local dir.

So the question is, what is this page that curl and "wget --spider" looking for and why did plain wget "find" this file and download its contents? Am I approaching this problem correctly (using curl or wget to see if the webservice is up and running) or am I attacking this problem wrong and should use something else to check?

Thanks in advance for your help.

¿Fue útil?

Solución

I suspect this is due to:

https://github.com/playframework/playframework/issues/2280

You'll need to make a regular GET call instead with an -i:

curl -is http://myapp.com | awk '/HTTP\/1.1 (.*) (.*?)/ {print $2}'

This should return 200 all is working.

One tip: in Chrome developer tools, in the network tab you can right click a request and 'Copy as cUrl'. You could compare this request with your handwritten cUrl request.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top