Sha256: 27d207c90d37779407498b2e0346cd84e98b7160e3e1b0af1b2f4c7978ea784a

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# -*- ruby -*-
#encoding: utf-8

require 'arborist/cli' unless defined?( Arborist::CLI )


# Command to start a Arborist daemon
module Arborist::CLI::Start
	extend Arborist::CLI::Subcommand

	desc 'Start an Arborist daemon'
	long_desc <<-EOF
	Start the Arborist manager, observers, or monitors. The SOURCE is
	passed to the loader to tell it where to load things from.
	EOF

	arg :DAEMON
	arg :SOURCE

	command :start do |cmd|

		cmd.flag :loader, desc: "Specify a loader type to use.",
			default_value: 'file'

		cmd.action do |globals, options, args|
			appname = args.shift
			source  = args.shift

			loader = Arborist::Loader.create( options.loader, source )
			runner = case appname
				when 'manager'
					Arborist.manager_for( loader )
				when 'monitors'
					Arborist.monitor_runner_for( loader )
				when 'observers'
					Arborist.observer_runner_for( loader )
				else
					raise "Don't know how to start %p" % [ appname ]
				end

			unless_dryrun( "starting #{appname}" ) do
				start( runner )
			end
		end
	end


	###############
	module_function
	###############

	### Start the specified +runner+ instance after setting up the environment for
	### it.
	def start( runner )
		$0 = runner.class.name
		runner.run
	end

end # module Arborist::CLI::Start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arborist-0.0.1.pre20160128152542 lib/arborist/command/start.rb