telefonicaid / perseo-fe

Front End process for the Perseo CEP
GNU Affero General Public License v3.0
15 stars 29 forks source link

[BUG] Docker sometimes when startup the perseo-core start slower than perseo-fe and fail with ECONNECTREFUSED #252

Open cesarjorgemartinez opened 7 years ago

cesarjorgemartinez commented 7 years ago

Docker sometimes when startup the perseo-core start slower than perseo-fe and fail with ECONNECTREFUSED (perseo-fe needs perseo-core startup process)

An analysis is performed and a synchronization between perseo-core and perseo-fe But this sync has a cost

Other better option is add a minimal delay in perseo-fe startup. Here we can do the following options:

echo "INFO: perseo-fe entrypoint start"

Use this environment variable:

PERSEO_CORE_URL=http://${PERSEOCORE_HOST}:${PERSEOCORE_PORT_CONT}

Use curl or tcping to check

Current time in seconds

STARTTIME=$(date +%s) while ! tcping -q -t 1 ${PERSEOCORE_HOST} ${PERSEOCORE_PORT_CONT} do [[ $(($(date +%s) - ${DBTIMEOUT})) -lt ${STARTTIME} ]] || { echo "ERROR: Timeout perseo-core endpoint <${PERSEO_CORE_URL}> Exceeds <${DBTIMEOUT}" >&2; exit 3; } echo "INFO: Wait for perseo-core endpoint <${PERSEO_CORE_URL}>" sleep 2 done echo "INFO: It took $(($(date +%s) - ${STARTTIME})) seconds to startup"

echo "INFO: Starting perseo-fe..." bin/perseo



- Add a nodejs native sleep inside bin/perseo

- We also have a restart always policy containers, but the error would be hidden
fgalan commented 7 years ago

Just to mention that the OnPremise framework has implemented a fix for this, based in tunning the entriypoint for perseo-fe instances in the docker compose .yml file.

Thus, in the OnPremise deployment the problem is solved, although the present issue stills having sense, as a pending fix for non-OnPremise deployments (note that Perseo dockers could be used outside OnPremise also).

agaldemas commented 6 years ago

I solve the issue by setting restart: on-failure for the perseo-fe service in docker-compose.yml not the cleanest way, but it works !