In Files

Class Index [+]

Quicksearch

TaskJuggler::Tj3Daemon

Public Class Methods

new() click to toggle source
    # File lib/tj3d.rb, line 26
26:     def initialize
27:       super
28:       @mandatoryArgs = '[<tjp file> [<tji file> ...] ...]'
29: 
30:       @log = LogFile.instance
31:       @log.logFile = File.join(Dir.getwd, "/#{AppConfig.appName}.log")
32:       @log.appName = AppConfig.appName
33:       @daemonize = true
34:       @uriFile = File.join(Dir.getwd, '.tj3d.uri')
35:       @port = nil
36:       @webServer = false
37:       @webServerPort = nil
38:     end

Public Instance Methods

error(message) click to toggle source
     # File lib/tj3d.rb, line 98
 98:     def error(message)
 99:       $stderr.puts "ERROR: #{message}"
100:       exit 1
101:     end
main() click to toggle source
    # File lib/tj3d.rb, line 75
75:     def main
76:       files = super
77:       broker = ProjectBroker.new
78:       @rc.configure(self, 'global')
79:       @rc.configure(@log, 'global.log')
80:       @rc.configure(broker, 'global')
81:       @rc.configure(broker, 'daemon')
82: 
83:       # Set some config variables if corresponding data was provided via the
84:       # command line.
85:       broker.port = @port if @port
86:       broker.uriFile = @uriFile.untaint
87:       broker.enableWebServer = @webServer
88:       broker.webServerPort = @webServerPort if @webServerPort
89:       broker.projectFiles = sortInputFiles(files) unless files.empty?
90:       broker.daemonize = @daemonize
91:       # Create log files for standard IO for each child process if the daemon
92:       # is not disconnected from the terminal.
93:       broker.logStdIO = !@daemonize
94: 
95:       broker.start
96:     end
processArguments(argv) click to toggle source
    # File lib/tj3d.rb, line 40
40:     def processArguments(argv)
41:       super do
42:         @opts.banner += The TaskJuggler daemon can be used to quickly generate reports for a numberof scheduled projects that are resident in memory. Once the daemon has beenstarted tj3client can be used to control it.
43:         @opts.on('-d', '--dont-daemonize',
44:                  format("Don't put program into daemon mode. Keep it " +
45:                         'connected to the terminal and show debug output.')) do
46:           @daemonize = false
47:         end
48:         @opts.on('-p', '--port <NUMBER>', Integer,
49:                  format('Use the specified TCP/IP port to serve tj3client ' +
50:                         'requests (Default: 8474).')) do |arg|
51:           @port = arg
52:         end
53:         @opts.on('--urifile', String,
54:                  format('If the port is 0, use this file to store the URI ' +
55:                         'of the server.')) do |arg|
56:           @uriFile = arg
57:         end
58:         @opts.on('-w', '--webserver',
59:                  format('Start a web server that serves the reports of ' +
60:                         'the loaded projects.')) do
61:           @webServer = true
62:         end
63:         @opts.on('--webserver-port <NUMBER>', Integer,
64:                  format('Use the specified TCP/IP port to serve web browser ' +
65:                         'requests (Default: 8080).')) do |arg|
66:           @webServerPort = arg
67:         end
68:       end
69:     end

Private Instance Methods

sortInputFiles(files) click to toggle source

Sort the provided input files into groups of projects. Each *.tjp file starts a new project. A *.tjp file may be followed by any number of *.tji files. The result is an Array of projects. Each consists of an Array like this: [ , (, …) ].

     # File lib/tj3d.rb, line 109
109:     def sortInputFiles(files)
110:       projects = []
111:       project = nil
112:       files.each do |file|
113:         if file[4..1] == '.tjp'
114:           # The project master file determines the working directory. If it's
115:           # an absolute file name, that directory will become the working
116:           # directory. If it's a relative file name, the current working
117:           # directory will be kept.
118:           if file[0] == '/'
119:             # Absolute file name
120:             workingDir = File.dirname(file)
121:             fileName = File.basename(file)
122:           else
123:             # Relative file name
124:             workingDir = Dir.getwd
125:             fileName = file
126:           end
127:           project = [ workingDir, fileName ]
128:           projects << project
129:         elsif file[4..1] == '.tji'
130:           # .tji files are optional. But if they are specified, they must
131:           # always follow the master file in the list.
132:           if project.nil?
133:             error("You must specify a '.tjp' file before the '.tji' files")
134:           end
135:           project << file
136:         else
137:           error("Project files must have a '.tjp' or '.tji' extension")
138:         end
139:       end
140: 
141:       projects
142:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.