Sha256: e81c48affe906bb05d817a22e462c178574cd3cec087462cb8d8e651a1d10ba1

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

require_relative '../../feature/php/merge_exec'

module IronWorkerNG
  module Code
    module Runtime
      module PHP
        include IronWorkerNG::Feature::PHP::MergeExec::InstanceMethods

        def runtime_bundle(container)
          container.get_output_stream(@dest_dir + '__runner__.php') do |runner|
            runner.write <<PHP_RUNNER
<?php
/* #{IronWorkerNG.full_version} */

function getArgs() {
  global $argv;

  $args = array('task_id' => null, 'dir' => null, 'payload' => array());

  foreach ($argv as $k => $v) {
    if (empty($argv[$k + 1])) continue;

    if ($v == '-id') $args['task_id'] = $argv[$k + 1];
    if ($v == '-d')  $args['dir']     = $argv[$k + 1];

    if ($v == '-payload' && file_exists($argv[$k + 1])) {
      $args['payload'] = file_get_contents($argv[$k + 1]);

      $parsed_payload = json_decode($args['payload']);

      if ($parsed_payload != NULL) {
        $args['payload'] = $parsed_payload;
      }
    }
  }

  return $args;
}

function getPayload() {
  $args = getArgs();

  return $args['payload'];
}

require '#{File.basename(@exec.path)}';
PHP_RUNNER
          end
        end

        def runtime_run_code(local = false)
          <<RUN_CODE
TERM=dumb php __runner__.php "$@"
RUN_CODE
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iron_worker_ng-0.10.2 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.10.1 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.10.0 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.6 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.5 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.4 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.2 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.1 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-0.9.0 lib/iron_worker_ng/code/runtime/php.rb