JavaScript Using Forever-Monitor in Node-Webkit using forever-monitor

I'm trying to get forever-monitor working in node-webkit. I've used it in node express applications in the past without any problems, but can't seem to make it work in this case.

I have an index.html file which references the server.js script which contains the following code which is executed on launch:

var forever = require('forever-monitor');

var child = new (forever.Monitor)('app.js', {
  max: 3,
  silent: false,
  options: []
});


child.on('exit', function () {
  console.log('app.js has exited after 3 restarts');
});

child.on('start', function () {
  console.log('app.js has started');
});

child.on('restart', function (){
  console.log('app.js restarted');
});


child.start();

The app.js file consists of the following code:

var Q = require('q'),
  gui = require('nw.gui'),
  express = require('express'),
  path = require('path'),
  fs = require('fs'),
  Config = require('./api/utils/config'),
  SessionService = require('./api/services/SessionService'),
  menu = new gui.Menu(),
  exec = require('child_process').exec,
  child;

var app = express();
var trayActive = false;
var tray;
var routePath = path.resolve('./api/controllers'); // Dynamically pull in all routes and pass in application

app.use(express.cookieParser());
app.use(express.json());
app.use(express.urlencoded());

fs.readdirSync(routePath).forEach(function (file) {
  var filePath = path.join(routePath, file);
  require(filePath)(app, openFile);
});

var server = app.listen(Config.expressPort, function () {
  console.log('Listening on port: ', server.address().port);     
  gui.Window.get().show();
});

When I 'npm start' I get the following output:

[970:0602/191500:INFO:CONSOLE(15)] ""app.js has started"", source: file:///Users/chris/webstorm-projects/myapp/server.js (15) execvp(): No such file or directory

Any insight would be greatly appreciated, and if you know of a working alternative method to accomplish restarts in node-webkit please let me know. Thanks.

Answer:1

I am currently working on importing png or svg files onto a canvas using the fabric.js library and an input file button. The code below works only if the image is in the root folder. I know that I don'...

I am currently working on importing png or svg files onto a canvas using the fabric.js library and an input file button. The code below works only if the image is in the root folder. I know that I don'...

Using the node.js console, I get the following unexpected results: > 2 + "3" "23" > 2 * "3" 6 Why does the first example favor string concatenation and integer multiplication in the second ...

Using the node.js console, I get the following unexpected results: > 2 + "3" "23" > 2 * "3" 6 Why does the first example favor string concatenation and integer multiplication in the second ...

  1. unexpected results in javascript

I know this has been discussed in other threads, but I've very new to coding websites in general, and when I try to use the solutions others have come up with, they just don't seem to work. And I ...

I know this has been discussed in other threads, but I've very new to coding websites in general, and when I try to use the solutions others have come up with, they just don't seem to work. And I ...

  1. twitter bootstrap close modal

I want users to be able to take a picture programmatically of a design they have made on my site . The design would be in a div that is a panorama that extends off both left/right edge of the screen. ...

I want users to be able to take a picture programmatically of a design they have made on my site . The design would be in a div that is a panorama that extends off both left/right edge of the screen. ...

  1. screenshot is possible with htmlunitdriver
  2. screenshot if possible
  3. screenshot not possible