Autostart @open-wa/wa-automate on Raspberry Pi using pm2

@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.

Install PM2:

Startup Script:

  • Navigate to open-wa directory using cd command cd /some-path/open-wa-directory.
  • Write a small shell script using nano editor nano start.sh and 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 20000 command.
  • –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. pm2 save.
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x