Skip to content

FreeBSD daemonize Node.js fails with crash while boot time #2411

Closed
@Zabrah

Description

@Zabrah
  • Node.js Version: 13.7
  • OS: Freebsd 12.1
  • Scope (install, code, runtime, meta, other?): runtime, rc.d script

Hi,
I am trying to get a Node.js app to run via an rc.d script in FreeBSD. While the OS runtime the rc.d script works fine and my app starts as expected.
But on system boot Node crashes. I didn't get enough info, so I traced the issue by logging some code-positions into a file via write-stream.

With this info Node.js seems to crash every time it comes to cluster.fork, but I cannot be 100% sure.
Could there be any dependency, that have to be waited for, before Node can safely be started while booting FreeBSD?

Here's the code of my rc.d script, with already some dependencies I thought they would be enough.

#!/bin/sh

# PROVIDE: testserver
# REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEMS
# BEFORE: 
# KEYWORD: shutdown

. /etc/rc.subr

name="testserver"

rcvar=${name}_enable

: ${miniserver_enable:="NO"}

pidfile="/var/run/testserver.pid"

command="/usr/sbin/daemon"
command_args="-u www -t 'Testserver Daemon' -P ${pidfile} -o /www/testserver/daemon.log -r /usr/local/bin/node /www/testserver/start.js"

load_rc_config $name
run_rc_command "$1"

I already searched the net for example startup scripts, but every of them are for using with the modules forever or pm2. But I want to try to get it working without them.

The only info coming from the daemon-service into the daemon.log is this (not even console.log infos are redirected into that file):

 1: 0x14fe830 node::Abort(void) [/usr/local/bin/node]
 2: 0x14d6aea node::PlatformInit(void) [/usr/local/bin/node]
 3: 0x14d6024 node::InitializeOncePerProcess(int, char**) [/usr/local/bin/node]
 4: 0x14d6479 node::Start(int, char**) [/usr/local/bin/node]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions