Starting/Ending PM2 web server
Issue #89
resolved
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)
-
-
reporter Thank you.
-
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.
-
reporter At the suggestion of Jesse Gorzinski, this works:
pm2 kill
Thanks Kevin.
-
reporter - changed status to resolved
- Log in to comment
You may get better help with this issue in our Ryvver forum. Links to the forum and signup link are in the main documentation page: https://bitbucket.org/ibmi/opensource/src/master/