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

daemonize mode causes error on startup #233

Open
ghost opened this issue Mar 25, 2021 · 4 comments
Open

daemonize mode causes error on startup #233

ghost opened this issue Mar 25, 2021 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 25, 2021

Hello,
we run frontail using following parameters:

frontail -d --disable-usage-stats -n 2000 \
  --ui-highlight-preset /tmp/frontail-preset --ui-highlight --pid-path /tmp/frontail.pid --log-path /tmp/frontail.log \
  /usr/java/jetty/logs/server.log

-d option causes following error at startup:

node:internal/fs/utils:815
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (930)
    at Object.writeFileSync (node:fs:1509:5)
    at module.exports (/usr/node/lib/node_modules/frontail/lib/daemonize.js:64:6)
    at Object.<anonymous> (/usr/node/lib/node_modules/frontail/index.js:47:3)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/usr/node/lib/node_modules/frontail/bin/frontail:2:1) {
  code: 'ERR_INVALID_ARG_TYPE'
}

log file (/tmp/frontail.log) is created, but empty,
pid file (/tmp/frontail.pid) isn't created at all,

  • frontail: 4.9.2 (4.9.1 the same)
  • node: v15.8.0
  • npm: 7.5.1

I don't know it is connected, but very often daemonized frontail dies with no trace.
Btw. we use jetty+frontail in dockerized container based on Centos 8

@BauerPh
Copy link

BauerPh commented Sep 16, 2021

same here... somone has a fix for this?

  • node: v16.9.1
  • npm: 7.21.1

Edit:
I've found a workaround:
start it with pm2

pm2 start frontail -- /var/log/logfile.log -t dark

@ghost
Copy link
Author

ghost commented Sep 20, 2021

Unfortunately project looks like a bit dead :/.

@lamuertepeluda
Copy link

The fix is trivial... just stringify this line https://github.com/mthenw/frontail/blob/master/lib/daemonize.js#L68

e.g. from

fs.writeFileSync(params.pidPath, proc.pid);

to

fs.writeFileSync(params.pidPath, String(proc.pid));

@lamuertepeluda
Copy link

While somebody takes care of this fix, I have found a workaround for daemonizing it in a Linux environment

damonize_frontail.sh

$FRONTAIL_LOGFILE=./frontail-log.log
FRONTAIL_PID_FILE=./frontail.pid
$LOGFILE=$1

# start frontail storing pid - put options here before $LOGFILE
frontail $LOGFILE &> $FRONTAIL_LOGFILE & frontail_pid=$! 

# write PID to disk
echo "$frontail_pid" > $FRONTAIL_PID_FILE

launch daemon: damonize_frontail.sh <logfile>

lately you can kill it like this

kill_frontail.sh

FRONTAIL_PID_FILE=./frontail.pid
$frontail_pid=cat $FRONTAIL_PID_FILE
kill $frontail_pid
rm $FRONTAIL_PID_FILE

Non-linux user should find a similar workaround for their OSes.

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

2 participants