menu

Questions & Answers

My NodeJS + Passenger crashes in the middle of the night almost every day

Hello and sorry for my (very) bad english and thank you in advance

I host a NodeJS app in a Plesk Obsidian server using Passenger ( i didn't chose Passenger btw ) and almost every day the app crashes ( it return a fatal error ) and i cannot use mysql and so... i have to restart my app manually from the plesk panel

I'm using NodeJS 19.4.0 & i saw someone who said to switch it to 14 but it changes nothing I'm also using express-session I also saw that was a bad idea for production but i said myself to not change to Aerospike or something compatible for production mode before i find out what's the problem

Here's my passenger.log file to the moment where he decided to be out of control There is a particularity I think in that log : around 8 o'clock it makes the "Session checked out from process" but it looks like he can't perform this task so retries multiples time then crash...

[ D 2023-01-22 00:31:18.8787 2815439/T8 age/Cor/App/Gro/SpawningAndRestarting.cpp:436 ]: Requested spawning of new process for group domain.name.com (development)
[ D 2023-01-22 00:31:18.8789 2815439/Tf age/Cor/Spa/DirectSpawner.h:239 ]: Spawning new process: appRoot=domain.name.com
[ D 2023-01-22 00:31:18.8813 2815439/Tf age/Cor/Spa/Han/Prepare.h:288 ]: [App spawn arg] {


[ D 2023-01-22 00:31:18.8837 2815439/Tf age/Cor/Spa/DirectSpawner.h:213 ]: Process forked for appRoot=domain.name.com: PID 2816902
App 2816902 output: Server listening on 5080
[ D 2023-01-22 00:31:20.0644 2815439/Tf age/Cor/Spa/Han/Perform.h:1782 ]: [App 2816902 journey] Loading state from /tmp/passenger.spawn.XXXXFjr89r/response
[ D 2023-01-22 00:31:20.0644 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_BEFORE_FIRST_EXEC: setting state to STEP_PERFORMED
[ D 2023-01-22 00:31:20.0645 2815439/Tf age/Cor/Spa/Han/Perform.h:1418 ]: [App 2816902 journey] Step SUBPROCESS_BEFORE_FIRST_EXEC: monotonic begin time is "5721884.895227"
[ D 2023-01-22 00:31:20.0645 2815439/Tf age/Cor/Spa/Han/Perform.h:1440 ]: [App 2816902 journey] Step SUBPROCESS_BEFORE_FIRST_EXEC: monotonic end time is "5721884.895227"
[ D 2023-01-22 00:31:20.0646 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_BEFORE_SHELL: setting state to STEP_PERFORMED
[ D 2023-01-22 00:31:20.0646 2815439/Tf age/Cor/Spa/Han/Perform.h:1418 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_BEFORE_SHELL: monotonic begin time is "5721884.895227"
[ D 2023-01-22 00:31:20.0646 2815439/Tf age/Cor/Spa/Han/Perform.h:1440 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_BEFORE_SHELL: monotonic end time is "5721884.927227"
[ D 2023-01-22 00:31:20.0647 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_OS_SHELL: setting state to STEP_NOT_STARTED
[ D 2023-01-22 00:31:20.0647 2815439/Tf age/Cor/Spa/Han/Perform.h:1418 ]: [App 2816902 journey] Step SUBPROCESS_OS_SHELL: monotonic begin time is "5721884.951227"
[ D 2023-01-22 00:31:20.0647 2815439/Tf age/Cor/Spa/Han/Perform.h:1440 ]: [App 2816902 journey] Step SUBPROCESS_OS_SHELL: monotonic end time is "5721884.951227"
[ D 2023-01-22 00:31:20.0648 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_AFTER_SHELL: setting state to STEP_PERFORMED
[ D 2023-01-22 00:31:20.0648 2815439/Tf age/Cor/Spa/Han/Perform.h:1418 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_AFTER_SHELL: monotonic begin time is "5721884.939227"
[ D 2023-01-22 00:31:20.0648 2815439/Tf age/Cor/Spa/Han/Perform.h:1440 ]: [App 2816902 journey] Step SUBPROCESS_SPAWN_ENV_SETUPPER_AFTER_SHELL: monotonic end time is "5721884.955227"
[ D 2023-01-22 00:31:20.0649 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_EXEC_WRAPPER: setting state to STEP_IN_PROGRESS
[ D 2023-01-22 00:31:20.0649 2815439/Tf age/Cor/Spa/Han/Perform.h:1418 ]: [App 2816902 journey] Step SUBPROCESS_EXEC_WRAPPER: monotonic begin time is "5721884.955227"
[ D 2023-01-22 00:31:20.0650 2815439/Tf age/Cor/Spa/Han/Perform.h:1448 ]: [App 2816902 journey] Step SUBPROCESS_EXEC_WRAPPER: end time is "1674347479.252", monotonic conversion is 5721885.255030
[ D 2023-01-22 00:31:20.0650 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_WRAPPER_PREPARATION: setting state to STEP_IN_PROGRESS
[ D 2023-01-22 00:31:20.0650 2815439/Tf age/Cor/Spa/Han/Perform.h:1426 ]: [App 2816902 journey] Step SUBPROCESS_WRAPPER_PREPARATION: begin time is "1674347479.252", monotonic conversion is 5721885.255031
[ D 2023-01-22 00:31:20.0651 2815439/Tf age/Cor/Spa/Han/Perform.h:1448 ]: [App 2816902 journey] Step SUBPROCESS_WRAPPER_PREPARATION: end time is "1674347479.316", monotonic conversion is 5721885.319031
[ D 2023-01-22 00:31:20.0651 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_APP_LOAD_OR_EXEC: setting state to STEP_IN_PROGRESS
[ D 2023-01-22 00:31:20.0651 2815439/Tf age/Cor/Spa/Han/Perform.h:1426 ]: [App 2816902 journey] Step SUBPROCESS_APP_LOAD_OR_EXEC: begin time is "1674347479.317", monotonic conversion is 5721885.320030
[ D 2023-01-22 00:31:20.0652 2815439/Tf age/Cor/Spa/Han/Perform.h:1448 ]: [App 2816902 journey] Step SUBPROCESS_APP_LOAD_OR_EXEC: end time is "1674347480.056", monotonic conversion is 5721886.059030
[ D 2023-01-22 00:31:20.0652 2815439/Tf age/Cor/Spa/Han/Perform.h:1207 ]: [App 2816902 journey] Step SUBPROCESS_LISTEN: setting state to STEP_IN_PROGRESS
[ D 2023-01-22 00:31:20.0652 2815439/Tf age/Cor/Spa/Han/Perform.h:1426 ]: [App 2816902 journey] Step SUBPROCESS_LISTEN: begin time is "1674347480.056", monotonic conversion is 5721886.059031
[ D 2023-01-22 00:31:20.0653 2815439/Tf age/Cor/Spa/Han/Perform.h:1448 ]: [App 2816902 journey] Step SUBPROCESS_LISTEN: end time is "1674347480.061", monotonic conversion is 5721886.064030
[ D 2023-01-22 00:31:20.0658 2815439/Tf age/Cor/Spa/DirectSpawner.h:224 ]: Process spawning done: appRoot=domain.name.com, pid=2816902
[ D 2023-01-22 00:31:20.0993 2815439/Tf age/Cor/App/Gro/ProcessListManagement.cpp:425 ]: Attaching process (pid=2816902, group=domain.name.com (development))
App 2816902 output: Mysql Connected...
[ D 2023-01-22 02:24:43.4718 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 04:46:12.9425 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 06:28:09.3295 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 07:59:49.9148 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 07:59:52.2975 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 07:59:54.5687 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 07:59:56.8566 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 07:59:57.1222 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 08:00:00.9978 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 08:00:03.2607 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 08:00:05.5239 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 08:00:07.7946 2815439/T8 age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
[ D 2023-01-22 08:00:08.0578 2815439/Ta age/Cor/App/Gro/SessionManagement.cpp:330 ]: Session checked out from process (pid=2816902, group=domain.name.com (development))
App 2816902 output: Error: read ECONNRESET
App 2816902 output:     at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
App 2816902 output:   errno: -104,
App 2816902 output:   code: 'ECONNRESET',
App 2816902 output:   syscall: 'read',
App 2816902 output:   fatal: true
App 2816902 output: }

And the log about the mysql error that i throwed :

App 2816902 output: Error from the database
App 2816902 output: Error: Cannot enqueue Query after fatal error

And finally how I make in NodeJS my queries because ChatGPT said me i have to "close my connections" after making a queries but i ain't really understood what he wanted to say:

db.query(sql, [values], function (err, result) {
    if (err) {

        return res.send({ msg: "error" })
    }
    if (result) {
        console.log("inserted well");
    }
});
Comments:
2023-01-23 00:05:03
Does Managing MySQL Connections (link is to an off-site resource) help?
Answers(0) :