Re: Starting Homebridge / nodejs daemon at boot

2024-04-04 Thread Manuel Kuklinski
Hi!

Am Dienstag 10 Oktober 2023 um 21:15:00 -0700, schrieb Renato Aguiar 0,3K:
> On Tue, Oct 10 2023, Manuel Kuklinski wrote:
> 
> > 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 posted a workaround for that in ports mailing list:
> https://marc.info/?l=openbsd-ports&m=169587505711635&w=2
> 
> -- 
> Renato Aguiar

I upgraded to 7.5 (thank you!) and everything is working flawlessly -
7.5 was already available on the official FTP servers.

Best wishes.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-16 Thread Manuel Kuklinski
Am Sonntag 15 Oktober 2023 um 16:47:37 -, schrieb Stuart Henderson 0,2K:
> On 2023-10-14, Manuel Kuklinski  wrote:
> > Thank you again - can you possibly direct me in the correct way to "dump
> > the environment"? I guess you don't mean `env`?
> 
> Yes, env - e.g. "(date; env) >> /tmp/env.log

Hi!

O.K., so my first guess wasn't that wrong - I thought there was a more
complex step involved, dumping the environment; maybe a nodejs switch -
sorry for the extra typing...

Nevertheless, that's the result:

# cat /tmp/env.log
Mon Oct 16 14:07:50 CEST 2023
_=/usr/bin/env
INRC=1
HOME=/
PWD=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin
Mon Oct 16 14:12:23 CEST 2023
_=/usr/bin/env
LOGNAME=root
TERM=xterm-256color
USER=root
HOME=/root
SHELL=/bin/ksh
PWD=/root
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin

I have no clue what to make of this, since the daemon receives a
SIGTERM, as visible in the debug log of homebridge (can be attached, if
needed). My wild guess would be the missing SHELL?! Help is appreciated
:-/

Kind regards.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-15 Thread Stuart Henderson
On 2023-10-14, Manuel Kuklinski  wrote:
> Thank you again - can you possibly direct me in the correct way to "dump
> the environment"? I guess you don't mean `env`?

Yes, env - e.g. "(date; env) >> /tmp/env.log




Re: Starting Homebridge / nodejs daemon at boot

2023-10-14 Thread Manuel Kuklinski
Am Samstag 14 Oktober 2023 um 17:14:40 +0100, schrieb Stuart Henderson 1,2K:
> On 2023/10/14 17:58, Manuel Kuklinski wrote:
> > Am Samstag 14 Oktober 2023 um 15:40:19 -, schrieb Stuart Henderson 1,0K:
> > > Is it any better if you do
> > > 
> > > daemon="/usr/local/bin/node"
> > > daemon_flags="/usr/local/bin/homebridge -T -Q -U /var/homebridge"
> > > 
> > > or does that not work at all anyway? (I don't know homebridge)
> > 
> > Hi!
> > 
> > Thank you for the input, but unfortunately this doesn't solve the problem.
> > 
> > For now I'm going to use the workaround Renato suggested, but I'd be
> > happy about a proper solution :-( Unfortunately I don't know what causes
> > this issue with homebridge / nodejs and have no clue where to start
> > searching...
> 
> I have definitely seen oddities with node and rc.d not working from
> pkg_scripts but it's always been on Dells which take about 10 minutes to
> boot and I've not been patient enough to track it down (and for whatever
> reason, the main one I had an issue with was the express-app one which
> works for me now anyway)...
> 
> If you want to investigate I suggest dumping the environmwnt to a file
> (maybe in rc_pre is enough, or maybe run the daemon via a wrapper script
> which dumps it) and compare for differences between when it's started at
> boot vs started after boot.

Hi!

Thank you again - can you possibly direct me in the correct way to "dump
the environment"? I guess you don't mean `env`?

>From what I could obeserve after enabling the debug flag of homebridge:
the service starts sucessfully, but receives a SIGTERM shortly after...

Mayber one more of your hints and I'm able to look more into this :-) 

Kind regards.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-14 Thread Manuel Kuklinski
Am Samstag 14 Oktober 2023 um 15:40:19 -, schrieb Stuart Henderson 1,0K:
> Is it any better if you do
> 
> daemon="/usr/local/bin/node"
> daemon_flags="/usr/local/bin/homebridge -T -Q -U /var/homebridge"
> 
> or does that not work at all anyway? (I don't know homebridge)

Hi!

Thank you for the input, but unfortunately this doesn't solve the problem.

For now I'm going to use the workaround Renato suggested, but I'd be
happy about a proper solution :-( Unfortunately I don't know what causes
this issue with homebridge / nodejs and have no clue where to start
searching...

Kind regards.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-14 Thread Stuart Henderson
On 2023/10/14 17:58, Manuel Kuklinski wrote:
> Am Samstag 14 Oktober 2023 um 15:40:19 -, schrieb Stuart Henderson 1,0K:
> > Is it any better if you do
> > 
> > daemon="/usr/local/bin/node"
> > daemon_flags="/usr/local/bin/homebridge -T -Q -U /var/homebridge"
> > 
> > or does that not work at all anyway? (I don't know homebridge)
> 
> Hi!
> 
> Thank you for the input, but unfortunately this doesn't solve the problem.
> 
> For now I'm going to use the workaround Renato suggested, but I'd be
> happy about a proper solution :-( Unfortunately I don't know what causes
> this issue with homebridge / nodejs and have no clue where to start
> searching...

I have definitely seen oddities with node and rc.d not working from
pkg_scripts but it's always been on Dells which take about 10 minutes to
boot and I've not been patient enough to track it down (and for whatever
reason, the main one I had an issue with was the express-app one which
works for me now anyway)...

If you want to investigate I suggest dumping the environmwnt to a file
(maybe in rc_pre is enough, or maybe run the daemon via a wrapper script
which dumps it) and compare for differences between when it's started at
boot vs started after boot.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-14 Thread Stuart Henderson
On 2023-10-10, Manuel Kuklinski  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:
>
> # cat /etc/rc.d/homebridge
> #!/bin/ksh
>
> daemon="/usr/local/bin/homebridge"
> daemon_user="_homebridge"
> daemon_flags="-T -Q -U /var/homebridge"
> daemon_class=daemon
> daemon_logger="daemon.info"
> daemon_execdir="/var/homebridge"
>
> . /etc/rc.d/rc.subr
>
> pexp="node: homebridge.*"
>
> rc_bg=YES
> rc_reload=NO
>
> rc_cmd $1
>
> What now? I'm happy about helping hands and hints...
>
> Kind regards.
>
>

Is it any better if you do

daemon="/usr/local/bin/node"
daemon_flags="/usr/local/bin/homebridge -T -Q -U /var/homebridge"

or does that not work at all anyway? (I don't know homebridge)

(I am using an express-app node script where I had problems
running at boot in the past, but it's working ok with the above).


-- 
Please keep replies on the mailing list.



Re: Starting Homebridge / nodejs daemon at boot

2023-10-12 Thread Aaron Mason
On Wed, Oct 11, 2023 at 11:38 AM Manuel Kuklinski  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



Re: Starting Homebridge / nodejs daemon at boot

2023-10-10 Thread Renato Aguiar

On Tue, Oct 10 2023, Manuel Kuklinski wrote:

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 posted a workaround for that in ports mailing list: 
https://marc.info/?l=openbsd-ports&m=169587505711635&w=2


--
Renato Aguiar



Starting Homebridge / nodejs daemon at boot

2023-10-10 Thread Manuel Kuklinski
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:

# cat /etc/rc.d/homebridge
#!/bin/ksh

daemon="/usr/local/bin/homebridge"
daemon_user="_homebridge"
daemon_flags="-T -Q -U /var/homebridge"
daemon_class=daemon
daemon_logger="daemon.info"
daemon_execdir="/var/homebridge"

. /etc/rc.d/rc.subr

pexp="node: homebridge.*"

rc_bg=YES
rc_reload=NO

rc_cmd $1

What now? I'm happy about helping hands and hints...

Kind regards.