Node Modules script invoked by NodeServices are terminated automatically ? #605

Closed
opened 2025-08-09 17:16:56 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @davidsekar on 7/7/2017

I'm using this package Highcharts Node.js export server to generate charts on the server side.

Here is the node js script that I invoke from NodeServices

const exporter = require('highcharts-export-server');

// Export settings 
// var exportSettings = {
//  type: 'png',
//  options: {
//    title: {
//      text: 'My Chart'
//    },
//    xAxis: {
//      categories: ["Jan", "Feb", "Mar", "Apr", "Mar", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
//    },
//    series: [
//      {
//        type: 'line',
//        data: [1, 3, 2, 4]
//      },
//      {
//        type: 'line',
//        data: [5, 3, 4, 2]
//      }
//    ]
//  }
// };

var exp = module.exports = {
  generateHighChart: (callback, chartOptions) => {
    try {

      var exportSettings = {
        type: 'png',
        options: chartOptions,
        scale: 2,
        sourceWidth: '1170',
        sourceHeight: '300'
      };

      exporter.logLevel(4);

      let config = {
        maxWorkers: 1,
        initialWorkers: 1,
        // reaper: false,
        listenToProcessExits: true
      };

      //exporter.log(4, 'Start Init');
      // Set up a pool of PhantomJS workers
      exporter.initPool(config);

      // Perform an export
      /*
          Export/Chart settings corresponds to the available CLI arguments described
          above.
      */
      exporter.export(exportSettings,
        (err, res) => {

          //exporter.log(4, JSON.stringify(res));
          try {
            // The export result is now in res.
            // If the output is not PDF or SVG, it will be base64 encoded (res.data).
            // If the output is a PDF or SVG, it will contain a filename (res.filename).
            // ret.data = res;
            //exporter.log(4, 'Received ' + res);
            // Kill the pool when we're done with it, and exit the application
            exporter.killPool();
            //process.exit(1);
          } catch (innerError) {
            // ret.err = innerError;
            exporter.log(4, 'Kill throws error : ' + innerError);
          }
          callback(err, JSON.stringify(res));
        });
    } catch (err) {
      //exporter.log(4, 'Try KillPool');
      exporter.killPool();
      //exporter.log(4, 'Kill succeeded');
      callback(err, null);
    };
  }
};
// exp.generateHighChart(function () { }, {});

.Net Core

result = await _nodeServices.InvokeExportAsync<string>("./client/modules/highcharts-image/generate-chart",
          "generateHighChart",
          chartOptions);

Even after completion of the execution, I see continuous message from the "Highcharts Node.js export server" i.e.,

reaper checking for timed out phantom processes

Seems that the Highcharts node server is using time out. which is not close by nodeservices

how to properly exit the invoked node script ?

*Originally created by @davidsekar on 7/7/2017* I'm using this package [Highcharts Node.js export server](https://github.com/highcharts/node-export-server) to generate charts on the server side. Here is the node js script that I invoke from NodeServices ``` const exporter = require('highcharts-export-server'); // Export settings // var exportSettings = { // type: 'png', // options: { // title: { // text: 'My Chart' // }, // xAxis: { // categories: ["Jan", "Feb", "Mar", "Apr", "Mar", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] // }, // series: [ // { // type: 'line', // data: [1, 3, 2, 4] // }, // { // type: 'line', // data: [5, 3, 4, 2] // } // ] // } // }; var exp = module.exports = { generateHighChart: (callback, chartOptions) => { try { var exportSettings = { type: 'png', options: chartOptions, scale: 2, sourceWidth: '1170', sourceHeight: '300' }; exporter.logLevel(4); let config = { maxWorkers: 1, initialWorkers: 1, // reaper: false, listenToProcessExits: true }; //exporter.log(4, 'Start Init'); // Set up a pool of PhantomJS workers exporter.initPool(config); // Perform an export /* Export/Chart settings corresponds to the available CLI arguments described above. */ exporter.export(exportSettings, (err, res) => { //exporter.log(4, JSON.stringify(res)); try { // The export result is now in res. // If the output is not PDF or SVG, it will be base64 encoded (res.data). // If the output is a PDF or SVG, it will contain a filename (res.filename). // ret.data = res; //exporter.log(4, 'Received ' + res); // Kill the pool when we're done with it, and exit the application exporter.killPool(); //process.exit(1); } catch (innerError) { // ret.err = innerError; exporter.log(4, 'Kill throws error : ' + innerError); } callback(err, JSON.stringify(res)); }); } catch (err) { //exporter.log(4, 'Try KillPool'); exporter.killPool(); //exporter.log(4, 'Kill succeeded'); callback(err, null); }; } }; // exp.generateHighChart(function () { }, {}); ``` .Net Core ``` result = await _nodeServices.InvokeExportAsync<string>("./client/modules/highcharts-image/generate-chart", "generateHighChart", chartOptions); ``` Even after completion of the execution, I see continuous message from the "Highcharts Node.js export server" i.e., > reaper checking for timed out phantom processes Seems that the Highcharts node server is using time out. which is not close by nodeservices how to properly exit the invoked node script ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#605
No description provided.