leandrosardi / pampa

Ruby library for async & distributed computing, supporting dynamic reconfiguration, distribution of the computation jobs, error handling, job-retry and fault tolerance, and fast (non-direct) communication to ensure real-time capabilities.
https://ConnectionSphere.com
1 stars 0 forks source link

Stand-alone processes #13

Open leandrosardi opened 1 year ago

leandrosardi commented 1 year ago

Descriptor

BlackStack::Pampa::add_proc(
        {
            # name must be unique
            # name cannot have spaces
            :name => 'leads.export',
            # node where this process will run
            :node => :n01,
            # location of the `proc.rb` file
            :working_directory => '/root/code/mysaas/p',
            # where to write the log
            :logfile => '/home/ubuntu/code/mysaas/export.log',
            # simple_command_line_parser descriptor
            # reference: https://github.com/leandrosardi/simple_command_line_parser
            :params => [
                { :name=>'foo', :value=>'bar' },
                { :name=>'foo2', :value=>'bar2'},
            ],
            # setup a minimum delay between cycles, in order to avoid database overworking.
            :min_cycle_seconds => 60,
            # script to run
            :processing_function => Proc.new do |*args|
                # TODO: Code Me!
            end,
        }
)

Process Running

BlackStack::Pampa.get_proc_command(:'leads.export')
=> "cd ~ & nohup ruby ~/code/mysaas/p/proc.rb name=leads.export foo=bar foo2=bar2 >/dev/null 2>&1 &"