@open-wa/orchestrator
Multi-session orchestration core logic

Generated from
packages/orchestrator/README.mdbyapps/docs/scripts/gen-workspace-readme-docs.js. Do not edit this page directly.
@open-wa/wa-orchestrate
Prerequisites
- NodeJS - v12.18.3
- npm
- npx
Installation
> npm iTest run
Make sure you have the cli installed by running:
> npx @open-wa/wa-automate --helpStart the management API
> npm run startPM2
Monitor the processes
> pm2 monitDelete all processes
> pm2 delete allCheck logs
> pm2 logsThe API
The API allows you to create, stop, delete, restart and proxy into sessions.
/create
/create is used to create a new @open-wa session.
POST /createBody:
{
//ID/Name of the session
"sessionId": "marketing",
//port on which to run the session. MUST BE UNIQUE!!
"port": 3002,
//Bas64 encoded sessionData [.data.json] string
"sessionData": "eyJXQU......==",
//URL of webhook where all SimpleListener [https://open-wa.github.io/wa-automate-nodejs/enums/simplelistener.html] events will be sent
"webhook": "https://webhook.site/0b4ac127-f84c-499c-a610-d809416c021c"
}/api/...
You can access the specific session APIs through this 'reverse proxy'. For the session above:
POST /api/marketingThe API explorer
You can explore all possible API requests for the relevant sessions using /api-docs/. Open this in a web browser:
GET /api/marketing/api-docs/Management API Postman collection
For your convience, you can import this postman collection
Troubleshooting
Puppeteer issues
If you get an error "while loading shared libraries" when trying out the npx command. Run the following
sudo apt-get install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libnss3-devor:
sudo yum install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libnss3-devIf you get this error:
internal/modules/cjs/loader.js:969 throw err;
^
Error: Cannot find module '/root/.npm/_npx/2862/lib/node_modules/@open-wa/wa-automate/node_modules/puppeteer/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}then you are most probably running as root. Puppeteer does not run as root so you will have to make a new user that will run the program. As root:
> adduser openwathen skip all of the details. Set a password then give them access to sudo
> usermod -aG sudo openwaThen change from root to that user
> su openwaThen go to the home directory (as root user you were most probably in /root which will cause further issues)
> cd ~Then try to run the CLI again to make sure everything is working properly
> npx @open-wa/wa-automateIt should now be able to start the session. If puppeteer is still causing issues try:
> npm i -g @open-wa/wa-automateIf this command results in a permissions error, you will have to change the npm cache folder permissions.
> sudo chown openwa -R /usr/lib/node_modulesthen try again:
> npm i -g @open-wa/wa-automateIf it was installed correctly, now try to run the CLI again:
> npx @open-wa/wa-automateIf the puppeteer issue is still happening on launch then try to install chrome on your machine:
> wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
> echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
> sudo apt-get update
> sudo apt-get install google-chrome-stable -yNow try to run the CLI again:
> npx @open-wa/wa-automateGoogle Compute Engine deployment
When deploying the docker image for this project in GCE (i.e 1 docker container on 1 VM running ContainerOS) you will need to use the following code to update the image
> gcloud beta compute instances update-container instance-1 --zone us-central1-a --container-image=us-central1-docker.pkg.dev/open-wa-31bb1/open-wa/wa-orch:latestFor example, on VM wa-orch-muhaimin in region us-central1-a then the command would be:
> gcloud beta compute instances update-container wa-orch-muhaimin --zone us-central1-a --container-image=us-central1-docker.pkg.dev/open-wa-31bb1/open-wa/wa-orch:latest
Was this helpful?
Wally and his cute companion coffee mug are coding day and night to keep this up-to-date!
