Sha256: 4937a3323c27f6889ec367ea231f310587233f006b25b5a024838244e49070ce

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

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

        def runtime_bundle(container, local = false)
          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(), 'config' => null);

  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;
      }
    }

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

      $parsed_config = json_decode($args['config'], true);

      if ($parsed_config != null) {
          $args['config'] = $parsed_config;
      }
    }
  }

  return $args;
}

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

  return $args['payload'];
}

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

  return $args['config'];
}

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

        def runtime_run_code(local, params)
          <<RUN_CODE
TERM=dumb php __runner__.php #{params}
RUN_CODE
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iron_worker_ng-1.6.1 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.5.2 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.5.1 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.5.0 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.4.2 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.4.1 lib/iron_worker_ng/code/runtime/php.rb
iron_worker_ng-1.4.0 lib/iron_worker_ng/code/runtime/php.rb