Re: Delay service startup but only on boot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/3/20 9:44 AM, Richard Shaw wrote:
On Thu, Dec 3, 2020 at 2:41 AM Gargoyle <g@xxxxxxxxxx <mailto:g@xxxxxxxxxx>> wrote:

    On 02/12/2020 16:09, Richard Shaw wrote:
    Nope, it's an external networked device. They always "boot up" at
    the same time, but the computer which runs the service boots up
    faster than the device I need to connect to.

    What difference does that make - what's the actual problem you're
    having?


The service starts and tries to connect but the other system is up far enough yet to receive connections so it just fails. The only solution so far is to restart the service manually later, which is what I'm trying to work around.

For remote connections, specially when all servers are restarted at the same time I use a shell script on ExecStartPre that check for an open port on the remote server.

My case it is a database server that takes a long time on the firmware initialization, and the application servers start really fast, before the database server is started.

########### wait-tcp-port <ip_or_hostname> <port>

#!/bin/bash

IP=$1
PORT=$2
MAX_TRIES=300

OPEN_RC=2
COUNTER=1
until [[ $OPEN_RC -eq 0 || $COUNTER -gt $MAX_TRIES ]]; do
  exec 3>&2 2>/dev/null
  exec 6<>/dev/tcp/$IP/$PORT
  OPEN_RC=$?
  exec 2>&3

  if [ $OPEN_RC -eq 0 ]; then
    exec 6>&- # close output connection
    exec 6<&- # close input connection
    echo Port $IP:$PORT open
  else
    sleep 2
    COUNTER=$[$COUNTER +1]
  fi
done

if [ $COUNTER -gt $MAX_TRIES ]; then
  echo Max tries waiting for port $IP:$PORT reached
  exit 100
fi


    Also, is this a standard Fedora package? (So there may at least be a
    weak link to continued discussion on this list)


No, it's something custom. Thanks for the feedback though, I pretty much already decided to try the timer delay method

Thanks,
Richard

_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx

_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux