SlideShare a Scribd company logo
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 29
Running QEWD as a Service
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
The QEWD Node.js process
• So far we've run it in a Command Prompt
or Terminal window
– This OK for demonstration
– But not for production
• It needs to run as a service
– Automatically start at boot time
– Restart on error
– Pipe console.log to a log file
Copyright © 2016 M/Gateway Developments Ltd
Running QEWD as a Service
• Different approaches needed for
– Windows
– Linux
• Many different options available, but the
following are two that seem to work well
Copyright © 2016 M/Gateway Developments Ltd
Running QEWD as a Service
• Windows:
– NSSM
• Linux
– PM2
Copyright © 2016 M/Gateway Developments Ltd
Windows: NSSM
• http://nssm.cc/
• Free Service Manager for Windows
• Works very well with Node.js and QEWD
• Click download and get the latest version
– 2.24 (at time of writing these notes)
Copyright © 2016 M/Gateway Developments Ltd
Install NSSM
• Drill down into the downloaded file
– Downloads/nssm-2.24.zip
• Find the /win64 directory
– Downloads/nssm-2.24.zip/nssm-2.24/win64/nssm.exe
• Copy nssm.exe to a directory that is
already in your PATH for executables, eg:
– C:Program Filesnodejs
Copyright © 2016 M/Gateway Developments Ltd
Log file for piped output
• Create a suitable directory, eg:
– C:qewdlog
• Create an empty file in it:
– qewd.log
Copyright © 2016 M/Gateway Developments Ltd
Dependency on Caché
• When NSSM starts up, it must wait to
make sure Caché has already started
– We need the dependency information
• Control Panel:
– System and Security
• Administrative Tools
– Services
Copyright © 2016 M/Gateway Developments Ltd
Dependency on Caché
• In the Services Window that opens up, find
the Service named:
– Caché Controller for Cachexxxx
• Right click on it and select Properties
• At the top you'll see the Service Name
– eg: Cache c- intersystems_cache2015-2
• Copy this to your clipboard
Copyright © 2016 M/Gateway Developments Ltd
Start NSSM Installer
• In a Command Prompt window type:
nssm install
• Application Path:
– C:Program Filesnodejsnode.exe
• Startup Directory:
– C:ewd3 (or wherever you start ewd-xpress)
• Arguments:
– ewd-xpress
• Click on Dependencies Tab
– Paste the Caché Service string from clipboard
• Click on I/O tab
– Input: leave blank
– Output: C:qewdlogqewd.log
– Error: C:qewdlogqewd.log
• Give your new service a name:
– QEWD
• Click Install Service
Copyright © 2016 M/Gateway Developments Ltd
Start the QEWD Service
• Switch to the Services window
• Click Refresh button
• QEWD should appear in the list of services
• Right-click on it and select Properties
– Service Status will be stopped
– Click Start
• QEWD should now be running
– Test by starting the qewd-monitor application
Copyright © 2016 M/Gateway Developments Ltd
Log File
• Look in C:qewdlogqewd.log
• You should see all the console.log activity
being piped there
Copyright © 2016 M/Gateway Developments Ltd
Controlling the Service
• Standard Windows Service
• Use the Services panel and find QEWD
– Stop
– Start
– Restart
• If an error occurs that stops the master process,
the QEWD service will automatically restart
• The QEWD service will start automatically when
Windows is re-booted
Copyright © 2016 M/Gateway Developments Ltd
NSSM additional features
• Lots more functionality
• Worth exploring documentation at
http://nssm.cc
• To edit your service definition:
– Open Command Prompt window
nssm edit QEWD
Copyright © 2016 M/Gateway Developments Ltd
Linux: PM2
• Advanced Node.js Process Manager
– http://pm2.keymetrics.io/
• Install:
– -g option makes pm2 available as a command
cd ~
sudo npm install –g pm2
Copyright © 2016 M/Gateway Developments Ltd
Start QEWD as a Service
cd ~/qewd
pm2 start qewd.js
Assuming that qewd.js is the name of your
QEWD startup file.
Copyright © 2016 M/Gateway Developments Ltd
Start QEWD as a Service
cd ~/qewd
pm2 start qewd.js
This will be now the PM2 Service name
Copyright © 2016 M/Gateway Developments Ltd
Monitor PM2 Services
cd ~/qewd
pm2 status
Displays the status of all your PM2 Services
- online
- stopped
Copyright © 2016 M/Gateway Developments Ltd
Stop the QEWD PM2 Service
cd ~/qewd
pm2 stop qewd
Copyright © 2016 M/Gateway Developments Ltd
Restart the QEWD PM2 Service
cd ~/qewd
pm2 start qewd
If you've already started QEWD as a service,
and if it appears as stopped in pm2 status,
you don't need to specify the .js file extension
Copyright © 2016 M/Gateway Developments Ltd
Restart the QEWD PM2 Service
cd ~/qewd
pm2 restart qewd
To stop and start QEWD again in 1 command
Copyright © 2016 M/Gateway Developments Ltd
Logging the output
• PM2 automatically pipes console.log and
error output to log files:
– ~/qewd/.pm2/logs
– You should find:
• ~/.pm2/logs/qewd-out-0.log
Copyright © 2016 M/Gateway Developments Ltd
Logging the output
• PM2 automatically pipes console.log and
error output to log files:
– ~/qewd/.pm2/logs
– You should find:
• ~/.pm2/logs/qewd-out-0.log
This number may vary
Copyright © 2016 M/Gateway Developments Ltd
Logging the output
• Use the tail command to monitor QEWD
activity in real-time
tail –f ~/.pm2/logs/qewd-out-0.log
Copyright © 2016 M/Gateway Developments Ltd
PM2 will auto-restart QEWD
• If an error brings down the QEWD master
process, PM2 will automatically restart it
• Try stopping the master process using
qewd-monitor while tailing the log file
– Watch it stop and immediately restart

More Related Content

PDF
EWD 3 Training Course Part 12: QEWD Session Timeout Control
PDF
EWD 3 Training Course Part 35: QEWD Session Locking
PDF
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
PDF
EWD 3 Training Course Part 19: The cache.node APIs
PDF
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
PDF
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
PDF
EWD 3 Training Course Part 27: The QEWD Session
PDF
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD
EWD 3 Training Course Part 12: QEWD Session Timeout Control
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 15: Using a Framework other than jQuery with QEWD

What's hot (20)

PDF
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
PDF
EWD 3 Training Course Part 16: QEWD Services
PDF
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
PDF
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
PDF
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
PDF
EWD 3 Training Course Part 30: Modularising QEWD Applications
PDF
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 11: Handling Errors in QEWD
PDF
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
PDF
EWD 3 Training Course Part 4: Installing & Configuring QEWD
PDF
EWD 3 Training Course Part 2: EWD 3 Overview
PPT
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
PPT
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
PPT
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
PPT
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
PPT
QEWD.js, JSON Web Tokens & MicroServices
PDF
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
EWD 3 Training Course Part 16: QEWD Services
EWD 3 Training Course Part 8: Anatomy of the QEWD Messaging Cycle
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 2: EWD 3 Overview
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
QEWD.js, JSON Web Tokens & MicroServices
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Ad

Viewers also liked (12)

PDF
EWD 3 Training Course Part 34: QEWD Resilient Mode
PPT
EWD 3 Training Course Part 42: The QEWD Docker Appliance
PDF
EWD 3 Training Course Part 26: Event-driven Indexing
PDF
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
PDF
EWD 3 Training Course Part 25: Document Database Capabilities
PDF
EWD 3 Training Course Part 21: Persistent JavaScript Objects
PDF
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
PDF
EWD 3 Training Course Part 20: The DocumentNode Object
PDF
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
PDF
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
PDF
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
PDF
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
Ad

Similar to EWD 3 Training Course Part 29: Running QEWD as a Service (20)

PDF
qewd-ripple: The Ripple OSI Middle Tier
PDF
Install VMWare Tools CentOS 7
PPTX
Deploying Windows Containers on Windows Server 2016
PDF
How to Transfer Magento Project from One Server to another Server
PDF
AWS Application Migration Service-Hands-On Guide
PDF
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
PDF
How to Install Node.js and NPM on Windows and Mac?
PDF
Prometheus and Docker (Docker Galway, November 2015)
PDF
Deploy django apps using docker
PPTX
Java App On Digital Ocean: Deploying With Gitlab CI/CD
PDF
Amazon AWS Workspace Howto
PDF
DevOpsDays Amsterdam Cosmic workshop
DOCX
Installation And Configuration Of DNS, Web And FTP Servers On Virtual Machine...
PDF
WordPress + Amazon Web Services Hands-on WARSAW
PDF
AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW
PDF
VMWare Tools Installation and Troubleshooting Guide
PDF
Cloudera cluster setup and configuration
PDF
OSDC.no 2015 introduction to node.js workshop
PPTX
Kraken.js Lab Primer
PDF
Chris Swan ONUG Academy - Container Networks Tutorial
qewd-ripple: The Ripple OSI Middle Tier
Install VMWare Tools CentOS 7
Deploying Windows Containers on Windows Server 2016
How to Transfer Magento Project from One Server to another Server
AWS Application Migration Service-Hands-On Guide
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
How to Install Node.js and NPM on Windows and Mac?
Prometheus and Docker (Docker Galway, November 2015)
Deploy django apps using docker
Java App On Digital Ocean: Deploying With Gitlab CI/CD
Amazon AWS Workspace Howto
DevOpsDays Amsterdam Cosmic workshop
Installation And Configuration Of DNS, Web And FTP Servers On Virtual Machine...
WordPress + Amazon Web Services Hands-on WARSAW
AMIMOTO: WordPress + Amazon Web Services Hands-on WARSAW
VMWare Tools Installation and Troubleshooting Guide
Cloudera cluster setup and configuration
OSDC.no 2015 introduction to node.js workshop
Kraken.js Lab Primer
Chris Swan ONUG Academy - Container Networks Tutorial

More from Rob Tweed (6)

PDF
QEWD Update
PPT
Data Persistence as a Language Feature
PPT
LNUG: Having Your Node.js Cake and Eating It Too
PPT
QEWD.js: Have your Node.js Cake and Eat It Too
PPT
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
PDF
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
QEWD Update
Data Persistence as a Language Feature
LNUG: Having Your Node.js Cake and Eating It Too
QEWD.js: Have your Node.js Cake and Eat It Too
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects

Recently uploaded (20)

DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
Introduction to Windows Operating System
PPTX
assetexplorer- product-overview - presentation
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Website Design Services for Small Businesses.pdf
How to Use SharePoint as an ISO-Compliant Document Management System
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Patient Appointment Booking in Odoo with online payment
"Secure File Sharing Solutions on AWS".pptx
Advanced SystemCare Ultimate Crack + Portable (2025)
Salesforce Agentforce AI Implementation.pdf
Cost to Outsource Software Development in 2025
Wondershare Recoverit Full Crack New Version (Latest 2025)
iTop VPN Crack Latest Version Full Key 2025
How Tridens DevSecOps Ensures Compliance, Security, and Agility
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Topaz Photo AI Crack New Download (Latest 2025)
Introduction to Windows Operating System
assetexplorer- product-overview - presentation
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
GSA Content Generator Crack (2025 Latest)
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Website Design Services for Small Businesses.pdf

EWD 3 Training Course Part 29: Running QEWD as a Service

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 29 Running QEWD as a Service Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd The QEWD Node.js process • So far we've run it in a Command Prompt or Terminal window – This OK for demonstration – But not for production • It needs to run as a service – Automatically start at boot time – Restart on error – Pipe console.log to a log file
  • 3. Copyright © 2016 M/Gateway Developments Ltd Running QEWD as a Service • Different approaches needed for – Windows – Linux • Many different options available, but the following are two that seem to work well
  • 4. Copyright © 2016 M/Gateway Developments Ltd Running QEWD as a Service • Windows: – NSSM • Linux – PM2
  • 5. Copyright © 2016 M/Gateway Developments Ltd Windows: NSSM • http://nssm.cc/ • Free Service Manager for Windows • Works very well with Node.js and QEWD • Click download and get the latest version – 2.24 (at time of writing these notes)
  • 6. Copyright © 2016 M/Gateway Developments Ltd Install NSSM • Drill down into the downloaded file – Downloads/nssm-2.24.zip • Find the /win64 directory – Downloads/nssm-2.24.zip/nssm-2.24/win64/nssm.exe • Copy nssm.exe to a directory that is already in your PATH for executables, eg: – C:Program Filesnodejs
  • 7. Copyright © 2016 M/Gateway Developments Ltd Log file for piped output • Create a suitable directory, eg: – C:qewdlog • Create an empty file in it: – qewd.log
  • 8. Copyright © 2016 M/Gateway Developments Ltd Dependency on Caché • When NSSM starts up, it must wait to make sure Caché has already started – We need the dependency information • Control Panel: – System and Security • Administrative Tools – Services
  • 9. Copyright © 2016 M/Gateway Developments Ltd Dependency on Caché • In the Services Window that opens up, find the Service named: – Caché Controller for Cachexxxx • Right click on it and select Properties • At the top you'll see the Service Name – eg: Cache c- intersystems_cache2015-2 • Copy this to your clipboard
  • 10. Copyright © 2016 M/Gateway Developments Ltd Start NSSM Installer • In a Command Prompt window type: nssm install • Application Path: – C:Program Filesnodejsnode.exe • Startup Directory: – C:ewd3 (or wherever you start ewd-xpress) • Arguments: – ewd-xpress • Click on Dependencies Tab – Paste the Caché Service string from clipboard • Click on I/O tab – Input: leave blank – Output: C:qewdlogqewd.log – Error: C:qewdlogqewd.log • Give your new service a name: – QEWD • Click Install Service
  • 11. Copyright © 2016 M/Gateway Developments Ltd Start the QEWD Service • Switch to the Services window • Click Refresh button • QEWD should appear in the list of services • Right-click on it and select Properties – Service Status will be stopped – Click Start • QEWD should now be running – Test by starting the qewd-monitor application
  • 12. Copyright © 2016 M/Gateway Developments Ltd Log File • Look in C:qewdlogqewd.log • You should see all the console.log activity being piped there
  • 13. Copyright © 2016 M/Gateway Developments Ltd Controlling the Service • Standard Windows Service • Use the Services panel and find QEWD – Stop – Start – Restart • If an error occurs that stops the master process, the QEWD service will automatically restart • The QEWD service will start automatically when Windows is re-booted
  • 14. Copyright © 2016 M/Gateway Developments Ltd NSSM additional features • Lots more functionality • Worth exploring documentation at http://nssm.cc • To edit your service definition: – Open Command Prompt window nssm edit QEWD
  • 15. Copyright © 2016 M/Gateway Developments Ltd Linux: PM2 • Advanced Node.js Process Manager – http://pm2.keymetrics.io/ • Install: – -g option makes pm2 available as a command cd ~ sudo npm install –g pm2
  • 16. Copyright © 2016 M/Gateway Developments Ltd Start QEWD as a Service cd ~/qewd pm2 start qewd.js Assuming that qewd.js is the name of your QEWD startup file.
  • 17. Copyright © 2016 M/Gateway Developments Ltd Start QEWD as a Service cd ~/qewd pm2 start qewd.js This will be now the PM2 Service name
  • 18. Copyright © 2016 M/Gateway Developments Ltd Monitor PM2 Services cd ~/qewd pm2 status Displays the status of all your PM2 Services - online - stopped
  • 19. Copyright © 2016 M/Gateway Developments Ltd Stop the QEWD PM2 Service cd ~/qewd pm2 stop qewd
  • 20. Copyright © 2016 M/Gateway Developments Ltd Restart the QEWD PM2 Service cd ~/qewd pm2 start qewd If you've already started QEWD as a service, and if it appears as stopped in pm2 status, you don't need to specify the .js file extension
  • 21. Copyright © 2016 M/Gateway Developments Ltd Restart the QEWD PM2 Service cd ~/qewd pm2 restart qewd To stop and start QEWD again in 1 command
  • 22. Copyright © 2016 M/Gateway Developments Ltd Logging the output • PM2 automatically pipes console.log and error output to log files: – ~/qewd/.pm2/logs – You should find: • ~/.pm2/logs/qewd-out-0.log
  • 23. Copyright © 2016 M/Gateway Developments Ltd Logging the output • PM2 automatically pipes console.log and error output to log files: – ~/qewd/.pm2/logs – You should find: • ~/.pm2/logs/qewd-out-0.log This number may vary
  • 24. Copyright © 2016 M/Gateway Developments Ltd Logging the output • Use the tail command to monitor QEWD activity in real-time tail –f ~/.pm2/logs/qewd-out-0.log
  • 25. Copyright © 2016 M/Gateway Developments Ltd PM2 will auto-restart QEWD • If an error brings down the QEWD master process, PM2 will automatically restart it • Try stopping the master process using qewd-monitor while tailing the log file – Watch it stop and immediately restart