module DockDriver
A namespace for the project & singleton for driving the dock.
Constants
- DATADIR
The path to the data directory for this gem.
- EXAMPLE_CONFIG_FILE
The location of the example config.
- REVISION
Project revision.
- USER_CONFIG_FILE
The default location of a user’s config file.
- USER_PID_FILE
The default location for the PID file.
- VERSION
Project version.
Attributes
dock[R]
The DockDriver::Dock
instance for the app.
loaded_config[RW]
The loaded config.
pager[R]
The DockDriver::WorkspacePager
instance for the app.
pid_file[RW]
The user’s PID file.
Public Class Methods
kill()
click to toggle source
Gracefully shut down the dock.
# File lib/dock_driver.rb, line 101 def self::kill self.pager.thread.kill self.dock.kill FileUtils.rm_f self.pid_file end
restart()
click to toggle source
Restart the dock.
# File lib/dock_driver.rb, line 91 def self::restart return unless self.loaded_config self.log.debug "Restarting." self.loaded_config.reload self.dock.restart rescue Exception => e self.log.warn "There was a problem with your config: %s" % [e.message] end
run( opts )
click to toggle source
Watch the config; initate a restart if it has been touched.
# File lib/dock_driver.rb, line 44 def self::run( opts ) # Manage a PID file. self.pid_file = opts[:pid_file] || USER_PID_FILE begin found_pid = File.read( self.pid_file ).to_i self.log.error "The dock appears to be running. Please " + "remove the PID file and kill the process if necessary." self.log.error "PID: %s File: %s" % [found_pid == 0 ? "Not found." : found_pid, self.pid_file] exit rescue Errno::ENOENT end File.write( self.pid_file, Process.pid ) # Load up the config. begin self.loaded_config = Configurability::Config.load( opts[:config] ) self.loaded_config.install rescue Exception => e self.log.error "I couldn't load your config: %s" % [e.message] return end # Start up the dock for the first time. self.dock.run self.pager.thread.run self.pager.add_observer dock loop do # Check for config updates if self.loaded_config.changed? self.log.debug "Config changed." self.restart end # Update the dock at once per second so that if the template # includes a time with seconds it gets updated as expected. sleep 1 self.dock.update end end