Sha256: 545afb0c5c2d39ebd2795aadf5946f63a9f0cd0688901b3a065a611f7ab51bb1

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../lib/kldockeragent'

def version?
	File.read(File.dirname(__FILE__) + '/../VERSION').strip
end

opts = Trollop::options do
	version "kldockeragent #{version?} (c) 2016 Kytoonlabs"
	banner <<-EOS
Agent for KL Docker Agent configuration management tool.
Usage:
       kldockeragent [options]

where [options] are:
EOS
	opt :start, "Start the agent. If --daemon option is set true, then the agent will start as a daemon.", :short => '-s'
	opt :stop, "Stop the daemon agent.", :short => '-t'
	opt :restart, "Restart the daemon agent.", :short => '-r'
	opt :status, "Print the status of the daemon agent.", :short => '-a'
	opt :pid, "Print the PID of the daemon agent."
end

if opts[:start]
	if not KL::Agent.pid.nil?
		puts "Agent is already running with PID #{KL::Agent.pid}"
	else
		opts[:daemon] = true
		KL::Agent.start(opts)
	end
elsif opts[:stop]
	KL::Agent.stop(opts)
elsif opts[:restart]
	KL.logger.info '[main] Restart Agent command detected.'
	opts[:daemon] = true
	KL::Agent.stop if KL::Agent.pid.to_i > 0
	KL::Agent.start(opts)
elsif opts[:status]
	KL::Agent.status
elsif opts[:pid]
	KL::Agent.get_pid
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kldockeragent-0.6.1 bin/kldockeragent
kldockeragent-0.5.9 bin/kldockeragent