Method: Arachni::Processes::Dispatchers#spawn

Defined in:
lib/arachni/processes/dispatchers.rb

#spawn(options = {}) ⇒ RPC::Client::Dispatcher

Spawns a RPC::Server::Dispatcher process.

Parameters:

  • options (Hash) (defaults to: {})

    To be passed to Options#set. Allows ‘address` instead of `rpc_server_address` and `port` instead of `rpc_port`.

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/arachni/processes/dispatchers.rb', line 66

def spawn( options = {} )
    fork = options.delete(:fork)

    options = {
        dispatcher: {
            neighbour:        options[:neighbour],
            node_pipe_id:     options[:pipe_id],
            node_weight:      options[:weight],
            external_address: options[:external_address],
            pool_size:        options[:pool_size]
        },
        rpc:        {
            server_port:    options[:port]    || available_port,
            server_address: options[:address] || '127.0.0.1'
        }
    }

    Manager.spawn( :dispatcher, options: options, fork: fork )

    url = "#{options[:rpc][:server_address]}:#{options[:rpc][:server_port]}"
    while sleep( 0.1 )
        begin
            connect( url, connection_pool_size: 1, max_retries: 1 ).alive?
            break
        rescue => e
            # ap e
        end
    end

    @list << url
    connect( url, fresh: true )
end