How do you launch highcharts under pm2?
I am upgrading an older version of highcharts-export-server to the latest and am no longer able to use it with pm2 on a windows server. How is everyone launching this?
In the documentation for highcharts-export-server, it says that you should use PM2 but this fails to work on windows. In the past, we were launching highcharts export server as a node module though a JS file through pm2. This appears to work still (no error) but it is unresponsive.
Obvious things first, I can launch it via command line, or using a batch without issue.
highcharts-export-server --port [my port num] --allowCodeExecution 1 --enableServer 1
or in a batch file
start cmd /k "highcharts-export-server --port [my port num] --allowCodeExecution 1 --enableServer 1"
If it is launched this way, everything works, but obviously this won't work in a professional environment, there is nothing to keep it alive. As has been posted before, I can't use pm2 with that command line because pm2 thinks those switches are pm2 switches. It seem like you have to create a JS file and launch highcharts as a node module to use pm2.
In the past we were launching it as a node module using the following code (which still should work reading the documenation here). I put this into a file named highcharts-server.js (which is referenced by pm2 below):
const exporter = require('highcharts-export-server');
exporter.initPool({initialWorkers:2});
exporter.startServer([my port num]);
Then that file could be launched via pm2 as follows (this launches 2 instances):
pm2 start highcharts-server.js -i 2
This worked on a very old version, and still appears to work now. There is no error but the server is completely unresponsive. I believe the reason this doesn't work now is that it is missing the required flags allowCodeExecution (we use callbacks) and enableServer. I can reproduce that same condition launching via command line by leaving them off.
How is everyone launching highcharts-export-server via pm2 on Windows? Is there a better way?
In the documentation most examples show passing the chart into an export call, but our app has always passed chart requests to this server which stays alive. Do I need to define the exporter.export(exportSettings, function (err, res) and export res to a file or something?
Any help is greatly appreciated, Thank you!