Module: DockDriver
- Extended by:
- Configurability, Loggability
- Defined in:
- lib/dock_driver.rb,
lib/dock_driver/i3.rb,
lib/dock_driver/dock.rb,
lib/dock_driver/template.rb,
lib/dock_driver/constants.rb,
lib/dock_driver/dock_item.rb,
lib/dock_driver/workspace_pager.rb
Overview
A namespace for the project & singleton for driving the dock.
Defined Under Namespace
Classes: Dock, DockItem, I3, Template, WorkspacePager
Constant Summary collapse
- VERSION =
Project version.
'0.3.4'- REVISION =
Project revision.
%$Revision: 842a417fe636 $- USER_CONFIG_FILE =
The default location of a user’s config file.
Pathname( '~/.dock_driver.yml' ).
- USER_PID_FILE =
The default location for the PID file.
Pathname( '~/.dock_driver.pid' ).
- DATADIR =
The path to the data directory for the musl gem.
begin dir = Gem.datadir('dock_driver') || Pathname( __FILE__ ).dirname.parent.parent + 'data/dock_driver' Pathname( dir ) end
- EXAMPLE_CONFIG_FILE =
The location of the example config.
Pathname( DATADIR + 'example.dock_driver.yml' ).
Class Attribute Summary collapse
-
.dock ⇒ Object
readonly
The DockDriver::Dock instance for the app.
-
.loaded_config ⇒ Object
The loaded config.
-
.pager ⇒ Object
readonly
The DockDriver::WorkspacePager instance for the app.
-
.pid_file ⇒ Object
The user’s PID file.
Class Method Summary collapse
-
.kill ⇒ Object
Gracefully shut down the dock.
-
.restart ⇒ Object
Restart the dock.
-
.run(opts) ⇒ Object
Watch the config; initate a restart if it has been touched.
Class Attribute Details
.dock ⇒ Object (readonly)
The DockDriver::Dock instance for the app.
31 32 33 |
# File 'lib/dock_driver.rb', line 31 def dock @dock end |
.loaded_config ⇒ Object
The loaded config.
37 38 39 |
# File 'lib/dock_driver.rb', line 37 def loaded_config @loaded_config end |
.pager ⇒ Object (readonly)
The DockDriver::WorkspacePager instance for the app.
34 35 36 |
# File 'lib/dock_driver.rb', line 34 def pager @pager end |
.pid_file ⇒ Object
The user’s PID file.
40 41 42 |
# File 'lib/dock_driver.rb', line 40 def pid_file @pid_file end |
Class Method Details
.kill ⇒ Object
Gracefully shut down the dock.
101 102 103 104 105 |
# 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 ⇒ Object
Restart the dock.
91 92 93 94 95 96 97 98 |
# 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.] end |
.run(opts) ⇒ Object
Watch the config; initate a restart if it has been touched.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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.] 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 |