Arborist::CLI::

Start

module
Extended With
Arborist::CLI::Subcommand

Command to start a Arborist daemon

Constants

VALID_DAEMONS

Public Class Methods

anchor
default_profile_filename( mode, runner )

Return a filename for a StackProf profile run over the given runner.

# File lib/arborist/command/start.rb, line 103
def self::default_profile_filename( mode, runner )
        basename = runner.class.name.gsub( /.*::/, '' )
        return "%s-%s-%s.%d.dump" % [
                basename,
                mode,
                Time.now.strftime('%Y%m%d%H%M%S'),
                Process.pid,
        ]
end
anchor
parse_profile_args( arg, runner )

Set up the StackProf profiler to run in the given mode.

# File lib/arborist/command/start.rb, line 94
def self::parse_profile_args( arg, runner )
        profile_mode, profile_filename = arg.split( ':', 2 )
        profile_filename ||= self.default_profile_filename( profile_mode, runner )

        return profile_mode, profile_filename
end
anchor
with_profiling_enabled( profile_arg, runner, &block )

Wrap the profiler around the specified callable.

# File lib/arborist/command/start.rb, line 81
def self::with_profiling_enabled( profile_arg, runner, &block )
        require 'stackprof'
        mode, outfile = self.parse_profile_args( profile_arg, runner )

        self.log.info "Profiling in %s mode, outputting to %s" % [ mode, outfile ]
        StackProf.run( mode: mode.to_sym, out: outfile, &block )
rescue LoadError => err
        self.log.debug "%p while loading the StackProf profiler: %s"
        exit_now!( "Couldn't load the profiler; you probably need to `gem install stackprof`", 254 )
end

Public Instance Methods

anchor
start( runner, profile_mode=nil )

Start the specified runner instance after setting up the environment for it.

# File lib/arborist/command/start.rb, line 67
def start( runner, profile_mode=nil )
        Process.setproctitle( runner.class.name )

        if profile_mode
                self.with_profiling_enabled( profile_mode, runner ) do
                        runner.run
                end
        else
                runner.run
        end
end