- Add NPM package
npm init
npm install --save math-to-image
- Create
math2image.js
with following code as an example
const MathToImage = require('math-to-image');
let mathToImage = new MathToImage();
mathToImage.start();
- Run the service
node math2image.js
Run using pm2 http://pm2.keymetrics.io.
The best way to make sure service is always up and running is to use pm2.
- Create
ecosystem.config.yml
using following code as an example:
module.exports = {
apps : [
{ name: 'Math2Image',
script: 'math2image.js',
instances: 1,
autorestart: true,
watch: true,
watch_delay: 1000,
ignore_watch : ["node_modules", ".git"],
max_memory_restart: '1G',
}
]
};
- Run service through pm2
pm2 start
- Check it's running using
pm2 ls
- Check logs using
pm2 logs