Pm2: env LD_PRELOAD not effect on Cluster Mode

Created on 30 Jul 2019  路  9Comments  路  Source: Unitech/pm2

https://github.com/Unitech/pm2/issues/3684
https://github.com/Unitech/pm2/issues/2618
https://github.com/lovell/sharp/issues/1803

What's going wrong?

Unable to load env LD_PRELOAD under Cluster Mode

How could we reproduce this issue?

Full detail here
https://github.com/lovell/sharp/issues/1803

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Tue Jul 30 2019 04:04:02 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.5.1
node version         : 12.6.0
node path            : not found
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ubuntu
uid                  : 1000
gid                  : 1000
uptime               : 40min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.5.1
node version         : 12.6.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : ubuntu
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
cpus nb              : 1
freemem              : 395948032
totalmem             : 1031700480
home                 : /home/ubuntu
===============================================================================
stale

Most helpful comment

Cluster mode is tightly linked on how PM2 has been started.
So if you want to load a specific LD_PRELOAD, you need to restart PM2 with that env variable.

So:

pm2 kill
LD_PRELOAD=xxxx pm2 ls
# Now if you start an app in cluster mode, LD_PRELOAD will be injected in that app
pm2 start app.js -i max

All 9 comments

@Unitech This issue still here for a long time, could you please take a look at this? Thanks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

The issue still here today

Facing the same issue. any suggestions?

Cluster mode is tightly linked on how PM2 has been started.
So if you want to load a specific LD_PRELOAD, you need to restart PM2 with that env variable.

So:

pm2 kill
LD_PRELOAD=xxxx pm2 ls
# Now if you start an app in cluster mode, LD_PRELOAD will be injected in that app
pm2 start app.js -i max

@Unitech How to ensure pm2 used LD_PRELOAD when system boot up?

@lokoArt
Currently,
I am using fork mode to prevent memory leak.
But that cause unable to provide zero-downtime service,
all update required between scheduled maintenance period like 02:00-03:00,
or accept the downtime when you need update immediate.

If set env LD_PRELOAD=xxxx before pm2 start that is work,
I will change all instance into cluster mode.

Successful to add LD_PRELOAD=xxxx into Cluster mode!
馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀

Add LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
Into /env/environment
Also do
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
Then
sudo reboot

The cluster mode will working with LD_PRELOAD=xxxx,
Not issue when processing many big size images with sharp.js,
Thanks to @Unitech provide some tips for this issue.

Successful to add LD_PRELOAD=xxxx into Cluster mode!
馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀馃帀

Add LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
Into /env/environment
Also do
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
Then
sudo reboot

The cluster mode will working with LD_PRELOAD=xxxx,
Not issue when processing many big size images with sharp.js,
Thanks to @Unitech provide some tips for this issue.

Where to place LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1, /env/environment isn't a valid directory?

Was this page helpful?
0 / 5 - 0 ratings