andresm
andresm

Reputation: 81

503 service unavailable openshift scalable app with symfony2

I created a new app at openshift. It's PHP 5.4 running a symfony project. I'm geting

503 Service Unavailable
No server is available to handle this request

APP cartridges:

I changed haproxy.cnf like says in an answer to the same problem with CodeIgniter (/MyCIapp/)

option httpchk GET /web/

but it didn't worked. I don't know if this is how it should be donde, i'm just trying as i google the error :S

here is my full haproxy.cnf

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    #log         127.0.0.1 local2

    maxconn     256

    # turn on stats unix socket
    stats socket /var/lib/openshift/53cf023e500446e8e40000b6/haproxy//run/stats level admin

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    #option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 128

listen stats 127.6.152.3:8080
    mode http
    stats enable
    stats uri /

listen express 127.6.152.2:8080

    cookie GEAR insert indirect nocache
    option httpchk GET /

    balance leastconn
    server local-gear 127.6.152.1:8080 check fall 2 rise 3 inter 2000 cookie local-53cf023e500446e8e40000b6
                                                                                                                                      66,4          Bot

Here is the rhc tail result:

==> app-root/logs/haproxy.log <==
[WARNING] 202/234012 (389054) : Server express/local-gear is DOWN for maintenance.
[WARNING] 202/234013 (389054) : Server express/local-gear is DOWN for maintenance.
[WARNING] 202/234017 (422420) : config : log format ignored for proxy 'stats' since it has no log address.
[WARNING] 202/234017 (422420) : config : log format ignored for proxy 'express' since it has no log address.
[WARNING] 202/234018 (422420) : Server express/local-gear is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 905ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 202/234018 (422420) : proxy 'express' has no server available!
[WARNING] 202/234021 (422420) : Server express/local-gear is DOWN for maintenance.
[WARNING] 202/234025 (422420) : Server express/local-gear is UP (leaving maintenance).
[WARNING] 202/234027 (422420) : Server express/local-gear is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 279ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 202/234027 (422420) : proxy 'express' has no server available!

==> app-root/logs/php.log <==
- - - [22/Jul/2014:23:40:38 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:40 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:42 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:44 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:47 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:49 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:51 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:53 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:55 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:40:58 -0400] "GET / HTTP/1.0" 404 554 "-" "-"

==> app-root/logs/haproxy_ctld.log <==
I, [2014-07-22T20:31:57.655534 #446960]  INFO -- : Starting haproxy_ctld
I, [2014-07-22T23:04:34.918141 #355794]  INFO -- : Starting haproxy_ctld
I, [2014-07-22T23:11:13.815573 #368500]  INFO -- : Starting haproxy_ctld
I, [2014-07-22T23:13:54.502196 #373865]  INFO -- : Starting haproxy_ctld
I, [2014-07-22T23:15:19.110173 #376596]  INFO -- : Starting haproxy_ctld
I, [2014-07-22T23:40:18.395416 #422460]  INFO -- : Starting haproxy_ctld

==> app-root/logs/php.log <==
- - - [22/Jul/2014:23:41:00 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:41:02 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:41:04 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:41:06 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:41:09 -0400] "GET / HTTP/1.0" 404 554 "-" "-"
- - - [22/Jul/2014:23:41:11 -0400] "GET / HTTP/1.0" 404 554 "-" "-"

Upvotes: 2

Views: 2015

Answers (2)

Tadhg
Tadhg

Reputation: 590

You're on the right track. Once you've SSH'ed in and are editing

haproxy/conf/haproxy.cfg

you need to change the line

option httpchk GET /

This should be a status URL on your app that will return a HTTP 200 when your application server status is working correctly, and a HTTP status 404 or 500-something when it is not. So you should embed a little status page in your app. Make it light, because HA proxy is going to be calling it frequently - mine just checks that there's a live DB connection in the pool and returns no content.

Then put the relative url in your haproxy.cfg's httpchk line like this

option httpchk GET /my-app/status

Upvotes: 2

andresm
andresm

Reputation: 81

The problem was:

option httpchk GET /

- - - [22/Jul/2014:23:40:40 -0400] "GET / HTTP/1.0" 404 554 "-" "-"

i got no route for / on my project.

The real problem is me not knowing anything about haproxy :)

It seems that when the route configured in the haproxy.cnf doesn't exists it doesn't starts the gear so it can't resolve any other valid route. The haproxy_status page shows it as DOWN. When i added a valid route for / in my project haproxy status showed the gear as UP and started working.

Upvotes: 2

Related Questions