iron_worker_ng 0.7.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/README.md +6 -7
  2. data/VERSION +1 -1
  3. data/bin/iron_worker +15 -42
  4. data/lib/iron_worker_ng/api_client.rb +33 -24
  5. data/lib/iron_worker_ng/client.rb +49 -10
  6. data/lib/iron_worker_ng/code/base.rb +136 -39
  7. data/lib/iron_worker_ng/code/binary.rb +4 -10
  8. data/lib/iron_worker_ng/code/builder.rb +10 -4
  9. data/lib/iron_worker_ng/code/java.rb +4 -22
  10. data/lib/iron_worker_ng/code/mono.rb +13 -0
  11. data/lib/iron_worker_ng/code/node.rb +4 -8
  12. data/lib/iron_worker_ng/code/php.rb +13 -0
  13. data/lib/iron_worker_ng/code/python.rb +13 -0
  14. data/lib/iron_worker_ng/code/ruby.rb +4 -89
  15. data/lib/iron_worker_ng/code/runtime/binary.rb +19 -0
  16. data/lib/iron_worker_ng/code/runtime/java.rb +31 -0
  17. data/lib/iron_worker_ng/code/runtime/mono.rb +17 -0
  18. data/lib/iron_worker_ng/code/runtime/node.rb +17 -0
  19. data/lib/iron_worker_ng/code/runtime/php.rb +59 -0
  20. data/lib/iron_worker_ng/code/runtime/python.rb +17 -0
  21. data/lib/iron_worker_ng/code/runtime/ruby.rb +96 -0
  22. data/lib/iron_worker_ng/feature/base.rb +1 -2
  23. data/lib/iron_worker_ng/feature/binary/merge_exec.rb +3 -5
  24. data/lib/iron_worker_ng/feature/common/merge_dir.rb +0 -4
  25. data/lib/iron_worker_ng/feature/common/merge_file.rb +0 -4
  26. data/lib/iron_worker_ng/feature/java/merge_exec.rb +3 -5
  27. data/lib/iron_worker_ng/feature/java/merge_jar.rb +0 -4
  28. data/lib/iron_worker_ng/feature/mono/merge_exec.rb +51 -0
  29. data/lib/iron_worker_ng/feature/node/merge_exec.rb +3 -5
  30. data/lib/iron_worker_ng/feature/php/merge_exec.rb +51 -0
  31. data/lib/iron_worker_ng/feature/python/merge_exec.rb +51 -0
  32. data/lib/iron_worker_ng/feature/ruby/merge_exec.rb +3 -5
  33. data/lib/iron_worker_ng/feature/ruby/merge_gem.rb +4 -4
  34. data/lib/iron_worker_ng/feature/ruby/merge_gemfile.rb +0 -4
  35. data/lib/iron_worker_ng.rb +9 -1
  36. data/remote_test.rb +3 -1
  37. metadata +18 -7
  38. data/lib/iron_worker_ng/code/creator.rb +0 -63
  39. data/lib/iron_worker_ng/code/initializer.rb +0 -76
@@ -8,43 +8,102 @@ require_relative '../feature/common/merge_dir'
8
8
  module IronWorkerNG
9
9
  module Code
10
10
  class Base
11
- attr_reader :features
11
+ attr_accessor :features
12
+ attr_accessor :fixators
13
+
12
14
  attr_accessor :base_dir
13
15
  attr_accessor :dest_dir
14
16
 
15
- @@registered_types = []
16
-
17
- def self.registered_types
18
- @@registered_types
19
- end
20
-
21
- def self.register_type(type)
22
- @@registered_types << type
23
- end
24
-
25
- @@registered_features = []
26
-
27
- def self.registered_features
28
- @@registered_features
29
- end
30
-
31
- def self.register_feature(feature)
32
- return if feature[:for_klass].to_s == 'IronWorkerNG::Code::Builder'
33
-
34
- @@registered_features << feature
35
- end
17
+ attr_accessor :inside_builder
36
18
 
37
- include IronWorkerNG::Code::Initializer::InstanceMethods
19
+ undef exec
38
20
 
39
21
  include IronWorkerNG::Feature::Common::MergeFile::InstanceMethods
40
22
  include IronWorkerNG::Feature::Common::MergeDir::InstanceMethods
41
23
 
42
24
  def initialize(*args, &block)
43
25
  @features = []
26
+ @fixators = []
27
+
44
28
  @base_dir = ''
45
29
  @dest_dir = ''
46
30
 
47
- initialize_code(*args, &block)
31
+ @runtime = nil
32
+
33
+ @name = nil
34
+ @exec = nil
35
+
36
+ @inside_builder = false
37
+
38
+ wfiles = []
39
+
40
+ if args.length == 1 && args[0].is_a?(String)
41
+ if args[0].end_with?('.worker') || args[0].end_with?('.workerfile')
42
+ @name = args[0].gsub(/\.worker$/, '').gsub(/\.workerfile$/, '')
43
+ else
44
+ @name = args[0]
45
+ end
46
+ elsif args.length == 1 && args[0].is_a?(Hash)
47
+ @name = args[0][:name] || args[0]['name']
48
+
49
+ wfile = args[0][:workerfile] || args[0]['workerfile']
50
+ wfiles << wfile unless wfile.nil?
51
+
52
+ exec = args[0][:exec] || args[0]['exec'] || args[0][:worker] || args[0]['worker']
53
+ unless exec.nil?
54
+ merge_exec(exec)
55
+ end
56
+ end
57
+
58
+ if @name.nil? and (not @exec.nil?)
59
+ @name = guess_name_for_path(@exec.path)
60
+ end
61
+
62
+ unless @name.nil?
63
+ wfiles << @name + '.worker'
64
+ wfiles << @name + '.workerfile'
65
+ end
66
+
67
+ wfiles << 'Workerfile'
68
+
69
+ wfiles.each do |wfile|
70
+ src, clean = IronWorkerNG::Fetcher.fetch(wfile)
71
+
72
+ unless src.nil?
73
+ IronCore::Logger.info 'IronWorkerNG', "Using workerfile #{wfile}"
74
+
75
+ eval(src)
76
+
77
+ @base_dir = File.dirname(wfile) == '.' ? '' : File.dirname(wfile) + '/'
78
+
79
+ break
80
+ end
81
+ end
82
+
83
+ unless block.nil?
84
+ instance_eval(&block)
85
+ end
86
+
87
+ if @name.nil? and (not @exec.nil?)
88
+ @name = guess_name_for_path(@exec.path)
89
+ end
90
+
91
+ unless @name.nil?
92
+ @name = File.basename(@name)
93
+ end
94
+ end
95
+
96
+ def method_missing(name, *args, &block)
97
+ if @runtime.nil?
98
+ runtime(:ruby)
99
+ send(name, *args, &block)
100
+ else
101
+ super(name, *args, &block)
102
+ end
103
+ end
104
+
105
+ def guess_name_for_path(path)
106
+ File.basename(path).gsub(/File.extname(path)$/, '').capitalize.gsub(/_./) { |x| x[1].upcase }
48
107
  end
49
108
 
50
109
  def name(name = nil)
@@ -67,17 +126,44 @@ module IronWorkerNG
67
126
  @remote_build_command = remote_build_command
68
127
  end
69
128
 
70
- def runtime(*args)
129
+ alias :build :remote_build_command
130
+ alias :build= :remote_build_command=
131
+
132
+ def runtime(runtime = nil)
133
+ return @runtime unless runtime
134
+
135
+ unless @runtime.nil?
136
+ IronCore::Logger.error 'IronWorkerNG', "Runtime is already set to #{@runtime}", IronCore::Error
137
+ end
138
+
139
+ runtime_module = nil
140
+ runtime = runtime.to_s
141
+
142
+ begin
143
+ runtime_module = IronWorkerNG::Code::Runtime.const_get(runtime.capitalize)
144
+ rescue
145
+ begin
146
+ runtime_module = IronWorkerNG::Code::Runtime.const_get(runtime.upcase)
147
+ rescue
148
+ end
149
+ end
150
+
151
+ if runtime_module.nil?
152
+ IronCore::Logger.error 'IronWorkerNG', "Can't find runtime '#{runtime}'"
153
+ end
154
+
155
+ self.extend(runtime_module)
156
+
157
+ @runtime = runtime
71
158
  end
72
159
 
73
160
  def runtime=(runtime)
161
+ runtime(runtime)
74
162
  end
75
163
 
76
164
  def fixate
77
- IronWorkerNG::Code::Base.registered_features.each do |rf|
78
- if (rf[:for_klass] == self.class || self.class == IronWorkerNG::Code::Builder) && respond_to?(rf[:name] + '_fixate')
79
- send(rf[:name] + '_fixate')
80
- end
165
+ @fixators.each do |f|
166
+ send(f)
81
167
  end
82
168
  end
83
169
 
@@ -87,16 +173,23 @@ module IronWorkerNG
87
173
  Digest::MD5.hexdigest(@features.map { |f| f.hash_string }.join)
88
174
  end
89
175
 
176
+ def runtime_bundle(zip)
177
+ end
178
+
179
+ def runtime_run_code
180
+ ''
181
+ end
182
+
90
183
  def bundle(zip)
91
184
  @features.each do |feature|
92
185
  feature.bundle(zip)
93
186
  end
94
187
 
95
- unless self.class == IronWorkerNG::Code::Base
188
+ unless @inside_builder
96
189
  zip.get_output_stream(@dest_dir + '__runner__.sh') do |runner|
97
190
  runner.write <<RUNNER
98
191
  #!/bin/sh
99
- # iron_worker_ng-#{IronWorkerNG.full_version}
192
+ # #{IronWorkerNG.full_version}
100
193
 
101
194
  root() {
102
195
  while [ $# -gt 1 ]; do
@@ -111,17 +204,18 @@ root() {
111
204
 
112
205
  cd "$(root "$@")"
113
206
 
114
- #{run_code}
207
+ #{runtime_run_code}
115
208
  RUNNER
116
209
  end
117
210
  end
211
+
212
+ runtime_bundle(zip)
118
213
  end
119
214
 
120
215
  def create_zip
121
- unless self.class == IronWorkerNG::Code::Base
122
- unless @exec
123
- IronCore::Logger.error 'IronWorkerNG', 'No exec specified'
124
- raise IronCore::IronError.new('No exec specified')
216
+ unless @inside_builder
217
+ if @exec.nil?
218
+ IronCore::Logger.error 'IronWorkerNG', 'No exec specified', IronCore::Error
125
219
  end
126
220
 
127
221
  if @name.nil?
@@ -149,18 +243,21 @@ RUNNER
149
243
  builder.remote_build_command = @remote_build_command
150
244
 
151
245
  builder.gem('iron_worker_ng')
152
- builder.fixate
153
246
 
247
+ builder.fixate
154
248
  builder.bundle(zip)
155
249
  end
250
+ end
156
251
 
252
+ if @remote_build_command
253
+ @dest_dir = ''
157
254
  end
158
255
 
159
256
  zip_name
160
257
  end
161
258
 
162
- def run_code
163
- ''
259
+ def to_s
260
+ "runtime='#{@runtime}', name='#{@name}', exec='#{@inside_builder ? '' : @exec.path}'"
164
261
  end
165
262
  end
166
263
  end
@@ -1,19 +1,13 @@
1
- require_relative '../feature/binary/merge_exec'
1
+ require_relative 'runtime/binary'
2
2
 
3
3
  module IronWorkerNG
4
4
  module Code
5
5
  class Binary < IronWorkerNG::Code::Base
6
- include IronWorkerNG::Feature::Binary::MergeExec::InstanceMethods
6
+ def initialize(*args, &block)
7
+ runtime(:binary)
7
8
 
8
- def run_code
9
- <<RUN_CODE
10
- chmod +x #{File.basename(@exec.path)}
11
-
12
- LD_LIBRARY_PATH=. ./#{File.basename(@exec.path)} "$@"
13
- RUN_CODE
9
+ super(*args, &block)
14
10
  end
15
11
  end
16
12
  end
17
13
  end
18
-
19
- IronWorkerNG::Code::Base.register_type(:name => 'binary', :klass => IronWorkerNG::Code::Binary)
@@ -2,11 +2,15 @@ require_relative '../feature/ruby/merge_gem'
2
2
 
3
3
  module IronWorkerNG
4
4
  module Code
5
- class Builder < IronWorkerNG::Code::Ruby
5
+ class Builder < IronWorkerNG::Code::Base
6
6
  def initialize(*args, &block)
7
7
  @features = []
8
+ @fixators = []
9
+
8
10
  @base_dir = ''
9
11
  @dest_dir = ''
12
+
13
+ runtime(:ruby)
10
14
  end
11
15
 
12
16
  def bundle(zip)
@@ -16,14 +20,14 @@ module IronWorkerNG
16
20
 
17
21
  zip.get_output_stream(@dest_dir + '__builder__.sh') do |builder|
18
22
  builder.write <<BUILDER_SH
19
- # iron_worker_ng-#{IronWorkerNG.full_version}
23
+ # #{IronWorkerNG.full_version}
20
24
  #{remote_build_command}
21
25
  BUILDER_SH
22
26
  end
23
27
 
24
28
  zip.get_output_stream(@dest_dir + '__builder__.rb') do |builder|
25
29
  builder.write <<BUILDER_RUBY
26
- # iron_worker_ng-#{IronWorkerNG.full_version}
30
+ # #{IronWorkerNG.full_version}
27
31
 
28
32
  require 'iron_worker_ng'
29
33
  require 'json'
@@ -33,10 +37,12 @@ exit 1 unless system('cd __build__ && sh ../__builder__.sh && cd ..')
33
37
  Dir.chdir('__build__')
34
38
 
35
39
  code = IronWorkerNG::Code::Base.new
40
+ code.inside_builder = true
41
+
36
42
  code.name params[:code_name]
37
43
  code.dir '.'
38
44
 
39
- client = IronWorkerNG::Client.new(:token => params[:iron_token], :project_id => params[:iron_project_id])
45
+ client = IronWorkerNG::Client.new(JSON.parse(params[:client_options]))
40
46
 
41
47
  res = client.codes.create(code, JSON.parse(params[:codes_create_options]))
42
48
 
@@ -1,31 +1,13 @@
1
- require_relative '../feature/java/merge_jar'
2
- require_relative '../feature/java/merge_exec'
1
+ require_relative 'runtime/java'
3
2
 
4
3
  module IronWorkerNG
5
4
  module Code
6
5
  class Java < IronWorkerNG::Code::Base
7
- include IronWorkerNG::Feature::Java::MergeJar::InstanceMethods
8
- include IronWorkerNG::Feature::Java::MergeExec::InstanceMethods
6
+ def initialize(*args, &block)
7
+ runtime(:java)
9
8
 
10
- def run_code
11
- classpath_array = []
12
-
13
- @features.each do |f|
14
- if f.respond_to?(:code_for_classpath)
15
- classpath_array << f.send(:code_for_classpath)
16
- end
17
- end
18
-
19
- classpath = classpath_array.join(':')
20
-
21
- IronCore::Logger.info 'IronWorkerNG', "Collected '#{classpath}' classpath"
22
-
23
- <<RUN_CODE
24
- java -cp #{classpath} #{@exec.klass.nil? ? "-jar #{File.basename(@exec.path)}" : @exec.klass} "$@"
25
- RUN_CODE
9
+ super(*args, &block)
26
10
  end
27
11
  end
28
12
  end
29
13
  end
30
-
31
- IronWorkerNG::Code::Base.register_type(:name => 'java', :klass => IronWorkerNG::Code::Java)
@@ -0,0 +1,13 @@
1
+ require_relative 'runtime/mono'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ class Mono < IronWorkerNG::Code::Base
6
+ def initialize(*args, &block)
7
+ runtime(:mono)
8
+
9
+ super(*args, &block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,17 +1,13 @@
1
- require_relative '../feature/node/merge_exec'
1
+ require_relative 'runtime/node'
2
2
 
3
3
  module IronWorkerNG
4
4
  module Code
5
5
  class Node < IronWorkerNG::Code::Base
6
- include IronWorkerNG::Feature::Node::MergeExec::InstanceMethods
6
+ def initialize(*args, &block)
7
+ runtime(:node)
7
8
 
8
- def run_code
9
- <<RUN_CODE
10
- node #{File.basename(@exec.path)} "$@"
11
- RUN_CODE
9
+ super(*args, &block)
12
10
  end
13
11
  end
14
12
  end
15
13
  end
16
-
17
- IronWorkerNG::Code::Base.register_type(:name => 'node', :klass => IronWorkerNG::Code::Node)
@@ -0,0 +1,13 @@
1
+ require_relative 'runtime/php'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ class PHP < IronWorkerNG::Code::Base
6
+ def initialize(*args, &block)
7
+ runtime(:python)
8
+
9
+ super(*args, &block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'runtime/python'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ class Python < IronWorkerNG::Code::Base
6
+ def initialize(*args, &block)
7
+ runtime(:python)
8
+
9
+ super(*args, &block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,98 +1,13 @@
1
- require_relative '../feature/ruby/merge_gem'
2
- require_relative '../feature/ruby/merge_gemfile'
3
- require_relative '../feature/ruby/merge_exec'
1
+ require_relative 'runtime/ruby'
4
2
 
5
3
  module IronWorkerNG
6
4
  module Code
7
5
  class Ruby < IronWorkerNG::Code::Base
8
- include IronWorkerNG::Feature::Ruby::MergeGem::InstanceMethods
9
- include IronWorkerNG::Feature::Ruby::MergeGemfile::InstanceMethods
10
- include IronWorkerNG::Feature::Ruby::MergeExec::InstanceMethods
6
+ def initialize(*args, &block)
7
+ runtime(:ruby)
11
8
 
12
- def bundle(zip)
13
- super(zip)
14
-
15
- zip.get_output_stream(@dest_dir + '__runner__.rb') do |runner|
16
- runner.write <<RUBY_RUNNER
17
- # iron_worker_ng-#{IronWorkerNG.full_version}
18
-
19
- module IronWorkerNG
20
- #{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/merge_initializer.rb')}
21
- #{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/indifferent_access.rb')}
22
- end
23
-
24
- class IronWorkerNGHash < Hash
25
- include IronWorkerNG::Hashie::Extensions::MergeInitializer
26
- include IronWorkerNG::Hashie::Extensions::IndifferentAccess
27
- end
28
-
29
- root = nil
30
- payload_file = nil
31
- task_id = nil
32
-
33
- 0.upto($*.length - 2) do |i|
34
- root = $*[i + 1] if $*[i] == '-d'
35
- payload_file = $*[i + 1] if $*[i] == '-payload'
36
- task_id = $*[i + 1] if $*[i] == '-id'
37
- end
38
-
39
- ENV['GEM_PATH'] = ([root + '__gems__'] + (ENV['GEM_PATH'] || '').split(':')).join(':')
40
-
41
- $:.unshift("\#{root}")
42
-
43
- require 'json'
44
-
45
- @iron_task_id = task_id
46
-
47
- @payload = File.read(payload_file)
48
-
49
- params = {}
50
- begin
51
- params = JSON.parse(@payload)
52
- rescue
53
- end
54
-
55
- @params = IronWorkerNGHash.new(params)
56
-
57
- def payload
58
- @payload
59
- end
60
-
61
- def params
62
- @params
63
- end
64
-
65
- def iron_task_id
66
- @iron_task_id
67
- end
68
-
69
- require '#{File.basename(@exec.path)}'
70
-
71
- unless #{@exec.klass == nil}
72
- exec_class = Kernel.const_get('#{@exec.klass}')
73
- exec_inst = exec_class.new
74
-
75
- params.keys.each do |param|
76
- if param.class == String
77
- if exec_inst.respond_to?(param + '=')
78
- exec_inst.send(param + '=', params[param])
79
- end
80
- end
81
- end
82
-
83
- exec_inst.run
84
- end
85
- RUBY_RUNNER
86
- end
87
- end
88
-
89
- def run_code
90
- <<RUN_CODE
91
- ruby __runner__.rb "$@"
92
- RUN_CODE
9
+ super(*args, &block)
93
10
  end
94
11
  end
95
12
  end
96
13
  end
97
-
98
- IronWorkerNG::Code::Base.register_type(:name => 'ruby', :klass => IronWorkerNG::Code::Ruby)
@@ -0,0 +1,19 @@
1
+ require_relative '../../feature/binary/merge_exec'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ module Runtime
6
+ module Binary
7
+ include IronWorkerNG::Feature::Binary::MergeExec::InstanceMethods
8
+
9
+ def runtime_run_code
10
+ <<RUN_CODE
11
+ chmod +x #{File.basename(@exec.path)}
12
+
13
+ LD_LIBRARY_PATH=. ./#{File.basename(@exec.path)} "$@"
14
+ RUN_CODE
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ require_relative '../../feature/java/merge_jar'
2
+ require_relative '../../feature/java/merge_exec'
3
+
4
+ module IronWorkerNG
5
+ module Code
6
+ module Runtime
7
+ module Java
8
+ include IronWorkerNG::Feature::Java::MergeJar::InstanceMethods
9
+ include IronWorkerNG::Feature::Java::MergeExec::InstanceMethods
10
+
11
+ def runtime_run_code
12
+ classpath_array = []
13
+
14
+ @features.each do |f|
15
+ if f.respond_to?(:code_for_classpath)
16
+ classpath_array << f.send(:code_for_classpath)
17
+ end
18
+ end
19
+
20
+ classpath = classpath_array.join(':')
21
+
22
+ IronCore::Logger.info 'IronWorkerNG', "Collected '#{classpath}' classpath"
23
+
24
+ <<RUN_CODE
25
+ java -cp #{classpath} #{@exec.klass.nil? ? "-jar #{File.basename(@exec.path)}" : @exec.klass} "$@"
26
+ RUN_CODE
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../feature/mono/merge_exec'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ module Runtime
6
+ module Mono
7
+ include IronWorkerNG::Feature::Mono::MergeExec::InstanceMethods
8
+
9
+ def runtime_run_code
10
+ <<RUN_CODE
11
+ mono #{File.basename(@exec.path)} "$@"
12
+ RUN_CODE
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../feature/node/merge_exec'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ module Runtime
6
+ module Node
7
+ include IronWorkerNG::Feature::Node::MergeExec::InstanceMethods
8
+
9
+ def runtime_run_code
10
+ <<RUN_CODE
11
+ node #{File.basename(@exec.path)} "$@"
12
+ RUN_CODE
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,59 @@
1
+ require_relative '../../feature/php/merge_exec'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ module Runtime
6
+ module PHP
7
+ include IronWorkerNG::Feature::PHP::MergeExec::InstanceMethods
8
+
9
+ def runtime_bundle(zip)
10
+ zip.get_output_stream(@dest_dir + '__runner__.php') do |runner|
11
+ runner.write <<PHP_RUNNER
12
+ <?php
13
+ /* #{IronWorkerNG.full_version} */
14
+
15
+ function getArgs() {
16
+ global $argv;
17
+
18
+ $args = array('task_id' => null, 'dir' => null, 'payload' => array());
19
+
20
+ foreach ($argv as $k => $v) {
21
+ if (empty($argv[$k + 1])) continue;
22
+
23
+ if ($v == '-id') $args['task_id'] = $argv[$k + 1];
24
+ if ($v == '-d') $args['dir'] = $argv[$k + 1];
25
+
26
+ if ($v == '-payload' && file_exists($argv[$k + 1])) {
27
+ $args['payload'] = file_get_contents($argv[$k + 1]);
28
+
29
+ $parsed_payload = json_decode($args['payload']);
30
+
31
+ if ($parsed_payload != NULL) {
32
+ $args['payload'] = $parsed_payload;
33
+ }
34
+ }
35
+ }
36
+
37
+ return $args;
38
+ }
39
+
40
+ function getPayload() {
41
+ $args = getArgs();
42
+
43
+ return $args['payload'];
44
+ }
45
+
46
+ require '#{File.basename(@exec.path)}';
47
+ PHP_RUNNER
48
+ end
49
+ end
50
+
51
+ def runtime_run_code
52
+ <<RUN_CODE
53
+ TERM=dumb php __runner__.php "$@"
54
+ RUN_CODE
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../feature/python/merge_exec'
2
+
3
+ module IronWorkerNG
4
+ module Code
5
+ module Runtime
6
+ module Python
7
+ include IronWorkerNG::Feature::Python::MergeExec::InstanceMethods
8
+
9
+ def runtime_run_code
10
+ <<RUN_CODE
11
+ python #{File.basename(@exec.path)} "$@"
12
+ RUN_CODE
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end