Module: IronWorkerNG::Code::Runtime::Node

Includes:
Feature::Common::MergeExec::InstanceMethods
Defined in:
lib/iron_worker_ng/code/runtime/node.rb

Instance Method Summary collapse

Methods included from Feature::Common::MergeExec::InstanceMethods

#merge_exec

Instance Method Details

#runtime_bundle(container, local = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/iron_worker_ng/code/runtime/node.rb', line 7

def runtime_bundle(container, local = false)
  container.get_output_stream(@dest_dir + 'node_modules/node_helper.js') do |runner|
    runner.write <<NODE_RUNNER
/* #{IronWorkerNG.full_version} */

var fs = require('fs');
var params = null;
var task_id = null;
var config = null;

process.argv.forEach(function(val, index, array) {
  if (val == "-payload") {
    params = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'));
  }

  if (val == "-config") {
    config = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'));
  }

  if (val == "-id") {
    task_id = process.argv[index + 1];
  }
});

exports.params = params;
exports.config = config;
exports.task_id = task_id;

NODE_RUNNER
  end
end

#runtime_run_code(local = false) ⇒ Object



39
40
41
42
43
# File 'lib/iron_worker_ng/code/runtime/node.rb', line 39

def runtime_run_code(local = false)
  <<RUN_CODE
node #{File.basename(@exec.path)} "$@"
RUN_CODE
end