Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cesarjorgemartinez opened this issue Jun 21, 2017 · 2 comments

Comments

@cesarjorgemartinez
Copy link
Contributor

cesarjorgemartinez commented Jun 21, 2017

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:

  • Inside Dockerfile replace:
    CMD bin/perseo
    by
    CMD sleep 0.5 && bin/perseo

  • Replace CMD by an entrypoint script and inside this script, before the bin/perseo startup insert a timeout check:

...
 # Define the entry point
  ENTRYPOINT ["/opt/perseo-fe/perseo-fe-entrypoint.sh"]

The sh

#!/bin/bash

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
Copy link
Member

fgalan commented Aug 2, 2017

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
Copy link

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants