@open-wa/wa-automate is a splendid open-source project to play with whatsapp. It also supports docker and Easy API making it more or less plug and play whatsapp automating program. In this short article we’ll focus on managing startup using PM2 which is an advanced process manager for Node.js applications.
- PM2 can be installed using npm package manager, For more information visit another article, Install and use Node Process Manager PM2.
- Navigate to open-wa directory using cd command
- Write a small shell script using nano editor
nano start.shand paste the following contents in it.
#!/bin/bash cd /home/pi/wa npx @open-wa/wa-automate --d --ras-pi --useChrome --multiDevice
- /home/pi/wa is the location where @open-wa/wa-automate is installed.
- –useChrome glag forces use of chromium instead of chrome browser.
- Save the file using Ctrl + X followed by Enter.
Running Startup Script with PM2:
- In the same directory, run
pm2 start start.sh --restart-delay 20000command.
- –restart-delay 20000 flag, adds the delay of 20 seconds necessary for startup of all dependencies and services prior running the script to ensure successful start of application.
- Save the process to bring it back on every reboot of system.