I had some troubles running whatsapp-web.js@1.23.0
here so I might as well share how I solved things.
- Make sure your machine has at least 1024MB of RAM otherwise OOM kills will be common:
fly scale memory 1024 -a APP_NAME
. - Create a 1GB volume for your machine and mount it (I’ve mounted mine at
/data
). - Use LocalAuth strategy.
- Use
fly logs -a APP_NAME
to see the QR Code.
The major pain was LocalAuth. I tried LocalAuth({ dataPath: '/data/whatsapp-data' })
where /data
was were my volume was mounted but it simply ignored therefor every time my machine restarted or I deploy it I had to do the QR Code again. So I did this to fix:
- Setup the QR code once.
fly ssh console -a APP_NAME
then check that your app folder contains awhatsapp-data
folder:mv whatsapp-data /data/whatsapp-data
so you persist it- Change your dockerfile like this:
--- a/Dockerfile
+++ b/Dockerfile
@@ -42,4 +42,4 @@ COPY --from=build /app /app
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
-CMD [ "npm", "run", "start" ]
+CMD [ "./prod_start.sh" ]
- Create a
prod_start.sh
file on your root.
ln -s /data/whatsapp-data /app/whatsapp-data
npm start
-
chmod +x prod_start.sh
-
fly deploy
You don’t need to do the QR Code anymore