fix: Puppeteer shm crash - add --disable-dev-shm-usage and /dev/shm volume
This commit is contained in:
parent
5fb2afec1d
commit
6449870836
|
|
@ -29,27 +29,36 @@ spec:
|
|||
containers:
|
||||
- name: whatsapp-gateway
|
||||
image: node:18-alpine
|
||||
# Install dependencies needed by Puppeteer inside Alpine
|
||||
# whatsapp-web.js requires Chromium
|
||||
command:
|
||||
- "sh"
|
||||
- "-c"
|
||||
- "apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont && cd /app && npm install && PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser node server.js"
|
||||
- "apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont && cd /app && npm install && node server.js"
|
||||
env:
|
||||
- name: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
|
||||
value: "true"
|
||||
- name: PUPPETEER_EXECUTABLE_PATH
|
||||
value: "/usr/bin/chromium-browser"
|
||||
volumeMounts:
|
||||
- name: app-code
|
||||
mountPath: /app
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
ports:
|
||||
- containerPort: 5001
|
||||
resources:
|
||||
requests:
|
||||
cpu: 300m
|
||||
memory: 512Mi
|
||||
memory: 768Mi
|
||||
limits:
|
||||
cpu: "1.5"
|
||||
memory: 1.5Gi
|
||||
cpu: "2"
|
||||
memory: 2Gi
|
||||
volumes:
|
||||
- name: app-code
|
||||
emptyDir: {}
|
||||
- name: dshm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
|
|
|||
|
|
@ -14,7 +14,20 @@ const client = new Client({
|
|||
}),
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || '/usr/bin/chromium-browser',
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-accelerated-2d-canvas',
|
||||
'--disable-gpu',
|
||||
'--no-first-run',
|
||||
'--no-zygote',
|
||||
'--single-process',
|
||||
'--disable-extensions',
|
||||
'--disable-background-networking',
|
||||
'--disable-default-apps'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -27,6 +40,16 @@ client.on('qr', (qr) => {
|
|||
console.log('==================================================================\n');
|
||||
qrcode.generate(qr, { small: true });
|
||||
console.log('\n==================================================================');
|
||||
console.log('[WhatsApp Bot] QR code generated. Waiting for scan...');
|
||||
});
|
||||
|
||||
// Log loading progress
|
||||
client.on('loading_screen', (percent, message) => {
|
||||
console.log(`[WhatsApp Bot] Loading: ${percent}% - ${message}`);
|
||||
});
|
||||
|
||||
client.on('authenticated', () => {
|
||||
console.log('[WhatsApp Bot] Authenticated successfully!');
|
||||
});
|
||||
|
||||
// Event: Successfully logged in & authenticated
|
||||
|
|
|
|||
Loading…
Reference in New Issue