/usr/bin/packet_worker_runner is in ruby-packet 0.1.15-5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 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 | #!/usr/bin/env ruby
PACKET_LIB_PATH = File.expand_path(File.dirname(__FILE__))
["lib"].each { |x| $LOAD_PATH.unshift(File.join(PACKET_LIB_PATH,"..",x))}
require "packet"
module Packet
class WorkerRunner
include Packet::NbioHelper
def initialize args
cmd_args = args.split(':')
worker_name = cmd_args[2]
initial_arg_data_length = cmd_args[3].to_i
@worker_root = cmd_args[4]
@worker_load_env = cmd_args[5]
@worker_read_fd = UNIXSocket.for_fd(cmd_args[0].to_i)
@worker_write_fd = UNIXSocket.for_fd(cmd_args[1].to_i)
initial_arg_data = @worker_read_fd.read(initial_arg_data_length)
Packet::WorkerRunner.const_set(:WORKER_OPTIONS,Marshal.load(initial_arg_data))
require @worker_load_env if @worker_load_env && !@worker_load_env.empty?
load_worker worker_name
end
def load_worker worker_name
if @worker_root && (File.file? "#{@worker_root}/#{worker_name}.rb")
require "#{@worker_root}/#{worker_name}"
worker_klass = Object.const_get(packet_classify(worker_name))
worker_klass.start_worker(:read_end => @worker_read_fd,:write_end => @worker_write_fd,:options => WORKER_OPTIONS)
else
require worker_name
worker_klass = Object.const_get(packet_classify(worker_name))
if worker_klass.is_worker?
worker_klass.start_worker(:read_end => @worker_read_fd,:write_end => @worker_write_fd,:options => WORKER_OPTIONS)
else
raise Packet::InvalidWorker.new(worker_name)
end
end
end
end
end
Packet::WorkerRunner.new(ARGV[0])
|