Starting/Ending PM2 web server

Issue #89 resolved
Michael Haston created an issue

Looking for advice on how to Start/End a PM2 web server from a job scheduler?

Here’s how I start the server:

PGM                                                          

ADDENVVAR  ENVVAR(QIBM_MULTI_THREADED) VALUE('Y')            
MONMSG     MSGID(CPFA980)                                    

SBMJOB     CMD(QSH +                                         
             CMD('/QOpenSys/etc/StartMyWebServer.sh')) +     
             LOG(4 0 *NOLIST) LOGCLPGM(*NO)                  

ENDPGM                                                       

This is the script it calls:

#!/QOpenSys/usr/bin/sh
cd /QOpenSys/etc;
PATH=/QOpenSys/pkgs/lib/nodejs10/bin:/QOpenSys/pkgs:/QOpenSys/pkgs/bin:$PATH;
export PATH;
pm2 stop all;
pm2 delete all;
pm2 start /QOpenSys/pkgs/lib/nodejs10/lib/node_modules/myscriipt.js > /QOpenSys/etc/myscriptlog.txt;

This was producing a ton of QP0ZSPWP logs, but I think I’ve gotten around that. Something odd is calling the CLP produces these two jobs. They work, my web server is started. I guess it’s not an issue until I try to end the server

Subsystem/Job  User        Type  CPU %  Function        Status 
XXXXX          QSYS        SBS      .0                   DEQW  
  QP0ZSPWP     XXXXXXXX    BCI      .0  PGM-node         SELW  
  QP0ZSPWP     XXXXXXXX    BCI      .0  PGM-node         SELW  

This script only ends one of the jobs!

#!/QOpenSys/usr/bin/sh
cd /QOpenSys/etc;
PATH=/QOpenSys/pkgs/lib/nodejs10/bin:/QOpenSys/pkgs:/QOpenSys/pkgs/bin:$PATH;
export PATH;
pm2 stop all;
pm2 delete all;

Thanks in advance.

Mike

Comments (5)

  1. Michael Haston reporter

    No luck over at the Ryvver forum after 22 days. Just wondering if anyone ends their PM2 server with a script like above. Thanks.

  2. Log in to comment