On Wed, Oct 11, 2023 at 11:38 AM Manuel Kuklinski <m...@asdfghasdfgh.de> wrote:
>
> Hi!
>
> I can't get homebridge started at boot - it starts with the following
> rc.d script if running as root after logging in, but fails to be present
> at boot time:
>

I have a similar issue with PHP and Perl based FastCGI apps. My
solution was a startup script that runs every minute in cron, that
would give me the ability to command a restart and offer a brake if
the program crashes. Something like this:

#!/bin/sh

NOSTART=~/path/to/nostart
KILLFILE=~/path/to/killfile
PIDFILE=~/path/to/pidfile

if [ -e "$KILLFILE" ]
then
    # Kill and cleanup
    kill `cat "$PIDFILE"`
    rm -f $KILLFILE $PIDFILE
elif [ -e "$PIDFILE" ]
then
    # Check if it's still running
    if ! kill -0 `cat "$PIDFILE" 2>/dev/null
    then
        rm -f $PIDFILE
    else
        exit 0
    fi
fi

# Don't try to start if the nostart file is there
[ -e "$NOSTART" ] && exit 0

/path/to/the/executable --option1 -o 2 &
echo $!>>$PIDFILE

# Create no start file so it doesn't try to restart after a failure
touch $NOSTART

-- 
Aaron Mason - Programmer, open source addict
I've taken my software vows - for beta or for worse

Reply via email to