lucagrulla / node-tail

The zero dependency Node.js module for tailing a file
https://www.lucagrulla.com/node-tail/
MIT License
467 stars 76 forks source link

Always on? #87

Closed fmarzocca closed 5 years ago

fmarzocca commented 5 years ago

I am using tail on a nodejs express server, to continuosly watch at a log file. Every time a line is added, I send a socket event to the browser client to add the line to a div.

Is there any resource/memory problem in leaving tail always on?

Thanks.

lucagrulla commented 5 years ago

The only memory concern you could encounter is if the log file grows much faster than what the library could consume. That depends on underline OS, CPU, disk etc so hard to clearly define.

Otherwise no memory leaks are expected.

fmarzocca commented 5 years ago

Thanks. My concern could be that I am not closing the “watch” . Has the close function a callback?

lucagrulla commented 5 years ago

If the goal is to continuously tail the file then "closign the watch" is not an option. If instead you do want to explicitly stop wathing the file then you can call "unwatch".

Please read the README documentation: https://github.com/lucagrulla/node-tail

for more details

fmarzocca commented 5 years ago

Sorry, I wasn't clear, my fault. I mean, if the server crashes and then restarts (it is monitored by forever), could it cause a leak not having unwatched the tail?

Il mar 11 giu 2019, 17:19 Luca Grulla notifications@github.com ha scritto:

If the goal is to continuously tail the file then "closign the watch" is not an option. If instead you do want to explicitly stop wathing the file then you can call "unwatch".

Please read the README documentation: https://github.com/lucagrulla/node-tail

for more details

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucagrulla/node-tail/issues/87?email_source=notifications&email_token=ACBCQ3VKUN5WFMZH4XDARETPZ667JA5CNFSM4HW63OB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNPR7I#issuecomment-500889853, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBCQ3XVIDQGWPXQGAHQWADPZ667JANCNFSM4HW63OBQ .

lucagrulla commented 5 years ago

I'm not sure to which server you are referring to in this scenario. What is going to crash?

If your NodeJS process crashes then all the code running on it dies, including tail library. If the server where the tailed file exist crashes then you most likely have an exception on your client nodeJS code, causing the library to exit.

fmarzocca commented 5 years ago

Clear. Thank you very much.

Il mar 11 giu 2019, 18:10 Luca Grulla notifications@github.com ha scritto:

I'm not sure to which server you are referring to in this scenario. What is going to crash?

If your NodeJS process crashes then all the code running on it dies, including tail library. If the server where the tailed file exist crashes then you most likely have an exception on your client nodeJS code, causing the library to exit.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucagrulla/node-tail/issues/87?email_source=notifications&email_token=ACBCQ3XDXO2UUSBEFU2XXR3PZ7E7RA5CNFSM4HW63OB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNVFEQ#issuecomment-500912786, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBCQ3RGGS3S5P3WMNKB3BLPZ7E7RANCNFSM4HW63OBQ .