In Files

Class Index [+]

Quicksearch

TaskJuggler::Tj3Daemon

Public Class Methods

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

Public Instance Methods

error(message) click to toggle source
    # File lib/tj3d.rb, line 94
94:     def error(message)
95:       $stderr.puts "ERROR: #{message}"
96:       exit 1
97:     end
main() click to toggle source
    # File lib/tj3d.rb, line 74
74:     def main
75:       files = super
76:       broker = ProjectBroker.new
77:       @rc.configure(self, 'global')
78:       @rc.configure(@log, 'global.log')
79:       @rc.configure(broker, 'global')
80:       @rc.configure(broker, 'daemon')
81: 
82:       # Set some config variables if corresponding data was provided via the
83:       # command line.
84:       broker.port = @port if @port
85:       broker.uriFile = @uriFile.untaint
86:       broker.enableWebServer = @webServer
87:       broker.webServerPort = @webServerPort if @webServerPort
88:       broker.projectFiles = sortInputFiles(files) unless files.empty?
89:       broker.daemonize = @daemonize
90: 
91:       broker.start
92:     end
processArguments(argv) click to toggle source
    # File lib/tj3d.rb, line 39
39:     def processArguments(argv)
40:       super do
41:         @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.
42:         @opts.on('-d', '--dont-daemonize',
43:                  format("Don't put program into daemon mode. Keep it " +
44:                         'connected to the terminal and show debug output.')) do
45:           @daemonize = false
46:         end
47:         @opts.on('-p', '--port <NUMBER>', Integer,
48:                  format('Use the specified TCP/IP port to serve tj3client ' +
49:                         'requests (Default: 8474).')) do |arg|
50:           @port = arg
51:         end
52:         @opts.on('--urifile', String,
53:                  format('If the port is 0, use this file to store the URI ' +
54:                         'of the server.')) do |arg|
55:           @uriFile = arg
56:         end
57:         @opts.on('-w', '--webserver',
58:                  format('Start a web server that serves the reports of ' +
59:                         'the loaded projects.')) do
60:           @webServer = true
61:         end
62:         @opts.on('--webserver-port <NUMBER>', Integer,
63:                  format('Use the specified TCP/IP port to serve web browser ' +
64:                         'requests (Default: 8080).')) do |arg|
65:           @webServerPort = arg
66:         end
67:       end
68:     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 105
105:     def sortInputFiles(files)
106:       projects = []
107:       project = nil
108:       files.each do |file|
109:         if file[4..1] == '.tjp'
110:           # The project master file determines the working directory. If it's
111:           # an absolute file name, that directory will become the working
112:           # directory. If it's a relative file name, the current working
113:           # directory will be kept.
114:           if file[0] == '/'
115:             # Absolute file name
116:             workingDir = File.dirname(file)
117:             fileName = File.basename(file)
118:           else
119:             # Relative file name
120:             workingDir = Dir.getwd
121:             fileName = file
122:           end
123:           project = [ workingDir, fileName ]
124:           projects << project
125:         elsif file[4..1] == '.tji'
126:           # .tji files are optional. But if they are specified, they must
127:           # always follow the master file in the list.
128:           if project.nil?
129:             error("You must specify a '.tjp' file before the '.tji' files")
130:           end
131:           project << file
132:         else
133:           error("Project files must have a '.tjp' or '.tji' extension")
134:         end
135:       end
136: 
137:       projects
138:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.