Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PM2 with highcharts-export-server in Windows does not work #348

Open
flaggalagga opened this issue Jun 3, 2022 · 1 comment
Open

Comments

@flaggalagga
Copy link

In the documentation for highcharts-export-server : it says that you should use PM2 to run it as a server but I just can't get this to work on my Windows machine.

I have no problem to run it from the command line :

highcharts-export-server --enableServer 1

However when I run :

pm2 start highcharts-export-server -- --enableServer 1

I get :

[PM2] Applying action restartProcessId on app [highcharts-export-server](ids: [ 0 ])
[PM2] [highcharts-export-server](0) ✓
[PM2] Process successfully started
┌─────┬─────────────────────────────┬─────────────┬─────────┬─────────┬──────────┬───────    ─┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ highcharts-export-server    │ default     │ N/A     │ fork    │ 13916    │ 0          │ 50   │ stopped   │ 0%       │ 0b       │ <ME> │ disabled │
└─────┴─────────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

It doesn't work and I get this error multiple times in highcharts-export-server-error.log :

C:\USERS\<ME>\APPDATA\ROAMING\NPM\HIGHCHARTS-EXPORT-SERVER.CMD:1
@ECHO off
^

SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Object.<anonymous> (C:\Users\lars\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:33:23)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)

I don't undertand what I'm doing wrong here because this works flawlessly on my Mac machine

@carguyrt
Copy link

carguyrt commented Jan 26, 2023

Was anyone ever able to launch highcharts-export-server via pm2 in windows? I can launch from command line or a batch file without issue, but pm2 fails due to the command line switches mentioned above.

An example of launching via commandline:
highcharts-export-server --port [my port num] --allowCodeExecution 1 --enableServer 1
From the cmd line this works or I can launch it from a bat using:
start cmd /k "highcharts-export-server --port [my port num] --allowCodeExecution 1 --enableServer 1"

but pm2 cannot handle those switches. In older versions of highcharts-export-server we were using a js file to set all of those properties, then launching that from pm2 (so it would keep it alive and we could have multiple instances). In this we had highcharts-server.js that contained:

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:
pm2 start highcharts-server.js -i 2

I don't see any documentation to support this with the new version of highcharts-export-server and I am having the same issue as the OP attempting to launch from pm2 using the command line as described in the documentation.
Did anyone solve the OP's question?
If not, are there alternatives that allow pm2?

Any help would be greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants