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
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# 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 "/* \#{IronWorkerNG.full_version} */\n\nvar fs = require('fs');\nvar querystring = require('querystring');\nvar params = null;\nvar task_id = null;\nvar config = null;\n\nprocess.argv.forEach(function(val, index, array) {\n if (val == \"-payload\") {\n params = fs.readFileSync(process.argv[index + 1], 'utf8');\n try {\n params = JSON.parse(params);\n } catch(e) {\n try {\nvar parsed = querystring.parse(params);\nif (!(Object.keys(parsed).length == 1 && parsed[Object.keys(parsed)[0]] == '')) {\n params = parsed\n}\n } catch(e) {\n\n }\n }\n }\n\n if (val == \"-config\") {\n config = JSON.parse(fs.readFileSync(process.argv[index + 1], 'utf8'));\n }\n\n if (val == \"-id\") {\n task_id = process.argv[index + 1];\n }\n});\n\nexports.params = params;\nexports.config = config;\nexports.task_id = task_id;\n\n"
end
end
|