bjrmatos / electron-workers

Run electron scripts in managed workers :rocket:
MIT License
142 stars 16 forks source link

Could not start all workers... #287

Open jbcripe68 opened 7 years ago

jbcripe68 commented 7 years ago

I'm trying to get a basic connection using ipc on Windows. I use your examples and still get the

{ Error: electron manager could not start all workers..

and

Error: ipc message could not be sent to electron process

I notice that if I purposely put a parsing error in the script.js or even pass a bogus name I get no warning that the process cannot be started.

Here is the installed packages. What am I doing wrong???

$ npm list convo-viewer@1.0.0 c:\development... +-- bluebird@3.4.6 +-- body-parser@1.17.2 extraneous +-- bunyan@1.8.9 | +-- dtrace-provider@0.8.1 | | -- nan@2.5.1 | +-- moment@2.18.1 | +-- mv@2.1.1 | | +-- ncp@2.0.0 | |-- rimraf@2.4.5 | | -- glob@6.0.4 |-- safe-json-stringify@1.0.4 +-- crc-32@0.4.1 | +-- concat-stream@1.6.0 | | +-- inherits@2.0.3 | | -- typedarray@0.0.6 |-- exit-on-epipe@1.0.0 +-- ejs@2.5.6 +-- ejs-lint@0.3.0 extraneous +-- electron-pdf@1.3.0 extraneous +-- electron-workers@1.10.3 extraneous +-- express@4.15.2 | +-- accepts@1.3.3 | | +-- mime-types@2.1.15 | | | -- mime-db@1.27.0 | |-- negotiator@0.6.1 | +-- array-flatten@1.1.1 | +-- content-disposition@0.5.2 | +-- content-type@1.0.2 | +-- cookie@0.3.1 | +-- cookie-signature@1.0.6 | +-- debug@2.6.1 | | -- ms@0.7.2 | +-- depd@1.1.0 | +-- encodeurl@1.0.1 | +-- escape-html@1.0.3 | +-- etag@1.8.0 | +-- finalhandler@1.0.1 | | +-- debug@2.6.3 | |-- unpipe@1.0.0 | +-- fresh@0.5.0 | +-- merge-descriptors@1.0.1 | +-- methods@1.1.2 | +-- on-finished@2.3.0 | | -- ee-first@1.1.1 | +-- parseurl@1.3.1 | +-- path-to-regexp@0.1.7 | +-- proxy-addr@1.1.4 | | +-- forwarded@0.1.0 | |-- ipaddr.js@1.3.0 | +-- qs@6.4.0 | +-- range-parser@1.2.0 | +-- send@0.15.1 | | +-- destroy@1.0.4 | | +-- http-errors@1.6.1 | | -- mime@1.3.4 | +-- serve-static@1.12.1 | +-- setprototypeof@1.0.3 | +-- statuses@1.3.1 | +-- type-is@1.6.14 | |-- media-typer@0.3.0 | +-- utils-merge@1.0.0 | -- vary@1.1.1 +-- filesize@3.5.6 +-- html-entities@1.2.1 +-- jsonfile@3.0.0 extraneous +-- mocha@3.2.0 | +-- browser-stdout@1.3.0 | +-- commander@2.9.0 | |-- graceful-readlink@1.0.1 | +-- debug@2.2.0 | | -- ms@0.7.1 | +-- diff@1.4.0 | +-- escape-string-regexp@1.0.5 | +-- glob@7.0.5 | | +-- fs.realpath@1.0.0 | | +-- inflight@1.0.6 | | |-- wrappy@1.0.2 | | +-- minimatch@3.0.3 | | | -- brace-expansion@1.1.6 | | | +-- balanced-match@0.4.2 | | |-- concat-map@0.0.1 | | +-- once@1.4.0 | | -- path-is-absolute@1.0.1 | +-- growl@1.9.2 | +-- json3@3.3.2 | +-- lodash.create@3.1.1 | | +-- lodash._baseassign@3.2.0 | | | +-- lodash._basecopy@3.0.1 | | |-- lodash.keys@3.1.2 | | | +-- lodash._getnative@3.9.1 | | | +-- lodash.isarguments@3.1.0 | | | -- lodash.isarray@3.0.4 | | +-- lodash._basecreate@3.0.3 | |-- lodash._isiterateecall@3.0.9 | +-- mkdirp@0.5.1 | | -- minimist@0.0.8 |-- supports-color@3.1.2 | -- has-flag@1.0.0 +-- moment@2.18.1 +-- pdfmake@0.1.28 | +-- linebreak@0.3.0 | | +-- base64-js@0.0.8 | | +-- brfs@1.4.3 | | | +-- quote-stream@1.0.2 | | | | +-- buffer-equal@0.0.1 | | | |-- minimist@1.2.0 | | | +-- resolve@1.3.3 | | | | -- path-parse@1.0.5 | | | +-- static-module@1.3.2 | | | | +-- duplexer2@0.0.2 | | | | |-- readable-stream@1.1.14 | | | | | -- isarray@0.0.1 | | | | +-- escodegen@1.3.3 | | | | | +-- esprima@1.1.1 | | | | | +-- estraverse@1.5.1 | | | | | +-- esutils@1.0.0 | | | | |-- source-map@0.1.43 | | | | | -- amdefine@1.0.1 | | | | +-- falafel@1.2.0 | | | | | +-- acorn@1.2.2 | | | | | +-- foreach@2.0.5 | | | | | +-- isarray@0.0.1 | | | | |-- object-keys@1.0.11 | | | | +-- has@1.0.1 | | | | | -- function-bind@1.1.0 | | | | +-- object-inspect@0.4.0 | | | | +-- quote-stream@0.0.0 | | | | +-- readable-stream@1.0.34 | | | | |-- isarray@0.0.1 | | | | +-- shallow-copy@0.0.1 | | | | +-- static-eval@0.2.4 | | | | | -- escodegen@0.0.28 | | | | | +-- esprima@1.0.4 | | | | |-- estraverse@1.3.2 | | | | -- through2@0.4.2 | | | |-- xtend@2.1.2 | | | | -- object-keys@0.4.0 | | |-- through2@2.0.3 | | -- unicode-trie@0.3.1 | | +-- pako@0.2.9 | |-- tiny-inflate@1.0.2 | +-- lodash@4.17.4 | -- pdfkit@0.8.0 | +-- fontkit@1.6.0 | | +-- babel-runtime@6.23.0 | | | +-- core-js@2.4.1 | | |-- regenerator-runtime@0.10.5 | | +-- brotli@1.3.2 | | | -- base64-js@1.2.0 | | +-- browserify-optional@1.0.0 | | | +-- ast-transform@0.0.0 | | | | +-- escodegen@1.2.0 | | | | +-- esprima@1.0.4 | | | |-- through@2.3.8 | | | +-- ast-types@0.7.8 | | | -- browser-resolve@1.11.2 | | |-- resolve@1.1.7 | | +-- clone@1.0.2 | | +-- deep-equal@1.0.1 | | +-- dfa@1.1.0 | | +-- restructure@0.5.4 | | -- unicode-properties@1.1.0 | +-- linebreak@0.1.2 | |-- unicode-trie@0.1.2 | -- png-js@0.1.1 +-- sanitize-html@1.14.1 | +-- htmlparser2@3.9.2 | | +-- domelementtype@1.3.0 | | +-- domhandler@2.4.1 | | +-- domutils@1.6.2 | | |-- dom-serializer@0.1.0 | | | -- domelementtype@1.1.3 | |-- entities@1.1.1 | +-- regexp-quote@0.0.0 | -- xtend@4.0.1 +-- uuid-validate@0.0.2 +-- yargs@5.0.0 | +-- cliui@3.2.0 | | +-- strip-ansi@3.0.1 | | |-- ansi-regex@2.1.1 | | -- wrap-ansi@2.1.0 | +-- decamelize@1.2.0 | +-- get-caller-file@1.0.2 | +-- lodash.assign@4.2.0 | +-- os-locale@1.4.0 | |-- lcid@1.0.0 | | -- invert-kv@1.0.0 | +-- read-pkg-up@1.0.1 | | +-- find-up@1.1.2 | | | +-- path-exists@2.1.0 | | |-- pinkie-promise@2.0.1 | | | -- pinkie@2.0.4 | |-- read-pkg@1.1.0 | | +-- load-json-file@1.1.0 | | | +-- parse-json@2.2.0 | | | | -- error-ex@1.3.1 | | | |-- is-arrayish@0.2.1 | | | +-- pify@2.3.0 | | | -- strip-bom@2.0.0 | | |-- is-utf8@0.2.1 | | +-- normalize-package-data@2.3.6 | | | +-- hosted-git-info@2.4.1 | | | +-- is-builtin-module@1.0.0 | | | | -- builtin-modules@1.1.1 | | | +-- semver@5.3.0 | | |-- validate-npm-package-license@3.0.1 | | | +-- spdx-correct@1.0.2 | | | | -- spdx-license-ids@1.2.2 | | |-- spdx-expression-parse@1.0.4 | | -- path-type@1.1.0 | +-- require-directory@2.1.1 | +-- require-main-filename@1.0.1 | +-- set-blocking@2.0.0 | +-- string-width@1.0.2 | | +-- code-point-at@1.1.0 | |-- is-fullwidth-code-point@1.0.0 | | -- number-is-nan@1.0.1 | +-- which-module@1.0.0 | +-- window-size@0.2.0 | +-- y18n@3.2.1 |-- yargs-parser@3.2.0 | -- camelcase@3.0.0 -- zip-stream@1.1.1 +-- archiver-utils@1.3.0 | +-- glob@7.1.1 | +-- graceful-fs@4.1.11 | +-- lazystream@1.0.0 | -- normalize-path@2.0.1 +-- compress-commons@1.2.0 | +-- buffer-crc32@0.2.13 |-- crc32-stream@2.0.0 | -- crc@3.4.4 -- readable-stream@2.2.6 +-- buffer-shims@1.0.0 +-- core-util-is@1.0.2 +-- isarray@1.0.0 +-- process-nextick-args@1.0.7 +-- string_decoder@0.10.31 `-- util-deprecate@1.0.2

npm ERR! extraneous: body-parser@1.17.2 c:\development\circuit\code\datastax\con vo-viewer\node_modules\body-parser npm ERR! extraneous: ejs-lint@0.3.0 c:\development\circuit\code\datastax\convo-v iewer\node_modules\ejs-lint npm ERR! extraneous: electron-pdf@1.3.0 c:\development\circuit\code\datastax\con vo-viewer\node_modules\electron-pdf npm ERR! extraneous: electron-workers@1.10.3 c:\development\circuit\code\datasta x\convo-viewer\node_modules\electron-workers npm ERR! extraneous: jsonfile@3.0.0 c:\development\circuit\code\datastax\convo-v iewer\node_modules\jsonfile

bjrmatos commented 7 years ago

Here is the installed packages. What am I doing wrong???

so far no clue.. the package seems to be working fine in my windows VM. you can try to run the example with the DEBUG env var to get more logs in the console, maybe there is more information there.


$> set DEBUG=electron-workers,electron-workers:*
$> // then start your application here
jbcripe68 commented 7 years ago

Looks like the child process is dying.

electron-workers:worker worker [671ef630-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +2ms

How can I test script.js??? Should it work with script.js written exactly as your example???

c:\Development\Circuit\code\datastax\convo-viewer>node startwork.js electron-workers:manager trying to get electron path from "electron" module.. +0ms electron-workers:manager trying to get electron path from "electron-prebuilt" module.. +6ms electron-workers:manager trying to get electron path from $PATH.. +4ms electron-workers Creating a new manager with options: { connectionMode: 'ipc',

pathToScript: 'script.js', timeout: 5000, numberOfWorkers: 5, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', maxConcurrencyPerWorker: Infinity, pingTimeout: 100, host: 'localhost', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT' } +11ms electron-workers:manager starting 5 worker(s), mode: ipc.. +6ms electron-workers:manager creating worker 1 with options: { debug: undefined, debugBrk: undefined, env: undefined, stdio: undefined, connectionMode: 'ipc', pingTimeout: 100, killSignal: undefined, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', pathToScript: 'script.js', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT', host: 'localhost', portLeftBoundary: undefined, portRightBoundary: undefined } +2ms electron-workers:worker starting worker [671b4cb0-8201-11e7-bbf3-07781e6032cf] .. +3ms electron-workers:worker spawning process for worker [671b4cb0-8201-11e7-bbf3-0 7781e6032cf] with args: [ 'script.js' ] and options: { env: { ELECTRON_WORKER_ID: '671b4cb0-8201-11e7-bbf3-07781e6032cf', DISPLAY: undefined }, stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] } +2ms electron-workers:worker electron process pid for worker [671b4cb0-8201-11e7-bb f3-07781e6032cf]: 8460 +17ms electron-workers:manager creating worker 2 with options: { debug: undefined, debugBrk: undefined, env: undefined, stdio: undefined, connectionMode: 'ipc', pingTimeout: 100, killSignal: undefined, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', pathToScript: 'script.js', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT', host: 'localhost', portLeftBoundary: undefined, portRightBoundary: undefined } +2ms electron-workers:worker starting worker [671ef630-8201-11e7-bbf3-07781e6032cf] .. +3ms electron-workers:worker spawning process for worker [671ef630-8201-11e7-bbf3-0 7781e6032cf] with args: [ 'script.js' ] and options: { env: { ELECTRON_WORKER_ID: '671ef630-8201-11e7-bbf3-07781e6032cf', DISPLAY: undefined }, stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] } +1ms electron-workers:worker electron process pid for worker [671ef630-8201-11e7-bb f3-07781e6032cf]: 11104 +9ms electron-workers:manager creating worker 3 with options: { debug: undefined, debugBrk: undefined, env: undefined, stdio: undefined, connectionMode: 'ipc', pingTimeout: 100, killSignal: undefined, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', pathToScript: 'script.js', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT', host: 'localhost', portLeftBoundary: undefined, portRightBoundary: undefined } +4ms electron-workers:worker starting worker [67220370-8201-11e7-bbf3-07781e6032cf] .. +5ms electron-workers:worker spawning process for worker [67220370-8201-11e7-bbf3-0 7781e6032cf] with args: [ 'script.js' ] and options: { env: { ELECTRON_WORKER_ID: '67220370-8201-11e7-bbf3-07781e6032cf', DISPLAY: undefined }, stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] } +2ms electron-workers:worker electron process pid for worker [67220370-8201-11e7-bb f3-07781e6032cf]: 592 +10ms electron-workers:manager creating worker 4 with options: { debug: undefined, debugBrk: undefined, env: undefined, stdio: undefined, connectionMode: 'ipc', pingTimeout: 100, killSignal: undefined, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', pathToScript: 'script.js', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT', host: 'localhost', portLeftBoundary: undefined, portRightBoundary: undefined } +4ms electron-workers:worker starting worker [672510b0-8201-11e7-bbf3-07781e6032cf] .. +4ms electron-workers:worker spawning process for worker [672510b0-8201-11e7-bbf3-0 7781e6032cf] with args: [ 'script.js' ] and options: { env: { ELECTRON_WORKER_ID: '672510b0-8201-11e7-bbf3-07781e6032cf', DISPLAY: undefined }, stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] } +2ms electron-workers:worker electron process pid for worker [672510b0-8201-11e7-bb f3-07781e6032cf]: 12840 +13ms electron-workers:manager creating worker 5 with options: { debug: undefined, debugBrk: undefined, env: undefined, stdio: undefined, connectionMode: 'ipc', pingTimeout: 100, killSignal: undefined, electronArgs: [], pathToElectron: 'C:\Program Files\nodejs\electron.CMD', pathToScript: 'script.js', hostEnvVarName: 'ELECTRON_WORKER_HOST', portEnvVarName: 'ELECTRON_WORKER_PORT', host: 'localhost', portLeftBoundary: undefined, portRightBoundary: undefined } +10ms electron-workers:worker starting worker [6729cba0-8201-11e7-bbf3-07781e6032cf] .. +6ms electron-workers:worker spawning process for worker [6729cba0-8201-11e7-bbf3-0 7781e6032cf] with args: [ 'script.js' ] and options: { env: { ELECTRON_WORKER_ID: '6729cba0-8201-11e7-bbf3-07781e6032cf', DISPLAY: undefined }, stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] } +9ms electron-workers:worker electron process pid for worker [6729cba0-8201-11e7-bb f3-07781e6032cf]: 13052 +26ms electron-workers:worker checking if worker [671b4cb0-8201-11e7-bbf3-07781e6032 cf] is alive.. +4ms electron-workers:worker checking if worker [671ef630-8201-11e7-bbf3-07781e6032 cf] is alive.. +25ms electron-workers:worker checking if worker [67220370-8201-11e7-bbf3-07781e6032 cf] is alive.. +18ms electron-workers:worker checking if worker [672510b0-8201-11e7-bbf3-07781e6032 cf] is alive.. +3ms electron-workers:worker checking if worker [6729cba0-8201-11e7-bbf3-07781e6032 cf] is alive.. +3ms electron-workers:worker worker [671ef630-8201-11e7-bbf3-07781e6032cf] onWorker ProcessExitTryToRecyle callback.. +164ms electron-workers:worker worker [671ef630-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +2ms electron-workers:worker worker [671b4cb0-8201-11e7-bbf3-07781e6032cf] onWorker ProcessExitTryToRecyle callback.. +21ms electron-workers:worker worker [671b4cb0-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +2ms electron-workers:worker worker [67220370-8201-11e7-bbf3-07781e6032cf] onWorker ProcessExitTryToRecyle callback.. +8ms electron-workers:worker worker [67220370-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +2ms electron-workers:worker worker [672510b0-8201-11e7-bbf3-07781e6032cf] onWorker ProcessExitTryToRecyle callback.. +56ms electron-workers:worker worker [672510b0-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +1ms electron-workers:worker worker [6729cba0-8201-11e7-bbf3-07781e6032cf] onWorker ProcessExitTryToRecyle callback.. +29ms electron-workers:worker worker [6729cba0-8201-11e7-bbf3-07781e6032cf] electron process exit with code: 1 and signal: null +2ms electron-workers:worker worker [671b4cb0-8201-11e7-bbf3-07781e6032cf] is not a live.. +20s electron-workers:worker worker [671ef630-8201-11e7-bbf3-07781e6032cf] is not a live.. +9ms electron-workers:worker worker [67220370-8201-11e7-bbf3-07781e6032cf] is not a live.. +2ms electron-workers:worker worker [672510b0-8201-11e7-bbf3-07781e6032cf] is not a live.. +2ms electron-workers:worker worker [6729cba0-8201-11e7-bbf3-07781e6032cf] is not a live.. +2ms electron-workers:manager electron manager could not start all workers.. +2ms { Error: electron manager could not start all workers.. at startHandler (c:\Development\Circuit\code\datastax\convo-viewer\node_modu les\electron-workers\lib\ElectronManager.js:170:37) at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\electron-w orkers\lib\ElectronWorker.js:331:20 at ElectronWorker.statusHandler (c:\Development\Circuit\code\datastax\convo- viewer\node_modules\electron-workers\lib\ElectronWorker.js:364:16) at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\electron-w orkers\lib\checkIpcStatus.js:43:9 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9) workerErrors: [ Error: ipc message could not be sent to electron process at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\elect ron-workers\lib\checkIpcStatus.js:43:12 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9), Error: ipc message could not be sent to electron process at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\elect ron-workers\lib\checkIpcStatus.js:43:12 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9), Error: ipc message could not be sent to electron process at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\elect ron-workers\lib\checkIpcStatus.js:43:12 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9), Error: ipc message could not be sent to electron process at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\elect ron-workers\lib\checkIpcStatus.js:43:12 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9), Error: ipc message could not be sent to electron process at c:\Development\Circuit\code\datastax\convo-viewer\node_modules\elect ron-workers\lib\checkIpcStatus.js:43:12 at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9) ] } electron-workers:manager process exit: trying to kill workers.. +17ms electron-workers:manager killing all workers.. +2ms electron-workers:worker killing worker [671b4cb0-8201-11e7-bbf3-07781e6032cf]. . +2ms electron-workers:worker killing worker [671ef630-8201-11e7-bbf3-07781e6032cf]. . +2ms electron-workers:worker killing worker [67220370-8201-11e7-bbf3-07781e6032cf]. . +1ms electron-workers:worker killing worker [672510b0-8201-11e7-bbf3-07781e6032cf]. . +1ms electron-workers:worker killing worker [6729cba0-8201-11e7-bbf3-07781e6032cf]. . +1ms

bjrmatos commented 7 years ago

How can I test script.js??? Should it work with script.js written exactly as your example???

according to the logs seems like electron is killing your process immediately, maybe there is something wrong in your script, like a syntax error or something.. is it the same as the example in docs?

it should work with the following:

// script.js

var app = require('electron').app;

var workerId = process.env.ELECTRON_WORKER_ID; // worker id useful for logging

console.log('Hello from worker', workerId);

app.on('ready', function() {
  // first you will need to listen the `message` event in the process object
  process.on('message', function(data) {
    if (!data) {
      return;
    }

    // `electron-workers` will try to verify is your worker is alive sending you a `ping` event
    if (data.workerEvent === 'ping') {
      // responding the ping call.. this will notify `electron-workers` that your process is alive
      process.send({ workerEvent: 'pong' });
    } else if (data.workerEvent === 'task') { // when a new task is executed, you will recive a `task` event

      console.log(data); //data -> { workerEvent: 'task', taskId: '....', payload: <whatever you have passed to `.execute`> }

      console.log(data.payload.someData); // -> someData

      // you can do whatever you want here..

      // when the task has been processed,
      // respond with a `taskResponse` event, the `taskId` that you have received, and a custom `response`.
      // You can specify an `error` field if you want to indicate that something went wrong
      process.send({
        workerEvent: 'taskResponse',
        taskId: data.taskId,
        response: {
          value: data.payload.someData
        }
      });
    }
  });
});
//Start electron workers

var electronWorkers = require('electron-workers')({
  connectionMode: 'ipc',
  pathToScript: 'script.js',
  timeout: 5000,
  numberOfWorkers: 5
});

electronWorkers.start(function(startErr) {
  if (startErr) {
    return console.error(startErr);
  }

  // `electronWorkers` will send your data in a POST request to your electron script
  electronWorkers.execute({ someData: 'someData' }, function(err, data) {
    if (err) {
      return console.error(err);
    }

    console.log(JSON.stringify(data)); // { value: 'someData' }
    electronWorkers.kill(); // kill all workers explicitly
  });
});
jbcripe68 commented 7 years ago

same results with that code. How can I debug what is happening in script.js???

My node version is v6.9.1

jbcripe68 commented 7 years ago

When I change the first console.log statement in script.js to:

fs.writeFileSync('c:\test.out', 'Hello from worker '+ workerId);

and change the numberOfWorkers parameter to 1 and pathToScript to 'c:\script.js' in startscript.js when I run from command line:

node startscript.js

I see the same output as above with only one "starting worker" and associated debug statements.

When I run:

electron c:\script.js

the process wait for me to hit Ctrl-C to stop it and I get my file c:\test.out with:

Hello from worker undefined

in it. Could it be the ' ' in my path to electron: pathToElectron: 'C:\Program Files\nodejs\electron.CMD',

bjrmatos commented 7 years ago

same results with that code. How can I debug what is happening in script.js???

the best way is to run it just with plain electron, but you have already tried that.

in it. Could it be the ' ' in my path to electron: pathToElectron: 'C:\Program Files\nodejs\electron.CMD',

how did you install electron? do you have it in PATH? or have you used the electron npm package? seems like you have the executable in your PATH and pointing to C:\Program Files\nodejs\.. can you please try with installing the electron package in your project and see how it goes.

bjrmatos commented 7 years ago

also it looks suspicious to me that you have the following in the end when doing npm ls, please try to do a fresh install.

npm ERR! extraneous: body-parser@1.17.2 c:\development\circuit\code\datastax\con vo-viewer\node_modules\body-parser npm ERR! extraneous: ejs-lint@0.3.0 c:\development\circuit\code\datastax\convo-v iewer\node_modules\ejs-lint npm ERR! extraneous: electron-pdf@1.3.0 c:\development\circuit\code\datastax\con vo-viewer\node_modules\electron-pdf npm ERR! extraneous: electron-workers@1.10.3 c:\development\circuit\code\datasta x\convo-viewer\node_modules\electron-workers npm ERR! extraneous: jsonfile@3.0.0 c:\development\circuit\code\datastax\convo-v iewer\node_modules\jsonfile

i have done another test in a fresh VM in it works again, using latest node 6.

captura de pantalla 2017-08-16 a las 10 12 31 a m

jbcripe68 commented 7 years ago

ok, after npm uninstall and reinstall the example code is working. Thanks

However, I am still having a problem maybe you can help with. My goal is to use the package electron-pdf to run tasks and convert requests from a local web-server into pdfs. I can only install this package with -g option. When I try to have my script.js require(electron-pdf) I get a window saying "module not found". I tried setting NODE_PATH in my DOS or GIT window and it still gives me the error. Any ideas??? I still suspect the " " in my NODE_PATH="C:\Program Files\nodejs\node_modules"

jbcripe68 commented 7 years ago

I was able to get around the electron-pdf dependency by putting a hard link in the node_modules under the app to the global location. Not ideal but it works.

So with that I've debugged the code to work on Windows... now to put it on Ubuntu. The problem there is I have to have a unique DISPLAY environment variable for each worker thread. I thought maybe I could key off the workerIds but they seem pretty random. Any way to do this???

modulitos commented 6 years ago

Seems related to this issue: https://github.com/bjrmatos/electron-workers/issues/278

I encountered the same electron manager could not start all workers.. bug, which only occurs on Linux. I was able to workaround this by install the xvfb package, described in the steps here:

https://github.com/electron/electron/blob/master/docs/tutorial/testing-on-headless-ci.md

TLDR, before starting my electron-workers app, I ran this:

export DISPLAY=':99.0' Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &

I hope there can be a more robust solution for this in the future - it seems like Linux support is rather crucial if we want this to run on most servers.