7 =head1 NAME $RCSfile: cqd.pl,v $
9 Clearquest Daemon - Daemon to provide access to Clearquest database
11 This daemon instanciates an instance of the Clearquest::DBService to service
12 requests for information of a Clearquest database or to update a Clearquest
21 Andrew DeFaria <Andrew@ClearSCM.com>
29 Mon Oct 24 16:19:15 PDT 2011
33 $Date: 2013/03/15 00:15:32 $
39 Usage: cqd.pl [-u|sage] [-v|erbose] [-d|ebug]
40 [-logfile <logfile>] [-[no]daemon]
41 [-s|erver <server>] [-p|ort <n>]
44 -u|sage: Displays usage
46 -de|bug: Output debug messages
48 -s|erver <server>: Server to talk to (Default: from conf file or
50 -p|ort <n> Port nbr to use (Default: from conf file or
53 -logfile <logfile>: Where to log output (Default: STDOUT)
54 -[no]daemon: Enter daemon mode (Default: Enter daemon mode)
56 -s|erver: For module = client or rest this is the name of the server
57 that will be providing the service
58 -p|ort: For module = client, this is the point on the server to talk
63 Options are keep in the cq.conf file in etc. They specify the default options
64 listed below. Or you can export the option name to the env(1) to override the
65 defaults in cq.conf. Finally you can programmatically set the options when you
66 call new by passing in a %parms hash. To specify the %parms hash key remove the
67 CQ_ portion and lc the rest.
69 =for html <blockquote>
75 Clearquest::Server name to connect to (Default: from config file)
79 Clearquest::Server port to connect to (Default: from config file)
92 use lib "$FindBin::Bin/../lib";
94 use Clearquest::Server;
98 my $VERSION = '$Revision: 2.4 $';
99 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
105 verbose => sub { set_verbose },
106 debug => sub { set_debug },
107 usage => sub { Usage },
118 CQ_SERVER => $opts{server},
119 CQ_PORT => $opts{port},
120 CQ_MULTITHREADED => $opts{multithreaded},
123 my $cqservice = Clearquest::Server->new (%parms);
125 if ($opts{serviceClient}) {
126 $cqservice->{clientname} = $opts{serviceClient};
128 debug "In cqd.pl with -serviceClient $cqservice->{clientname} - opening socket";
130 open my $client, '+<&=', *STDIN
131 or error "Unable to open socket connection to client", 1;
133 $client->autoflush (1);
135 debug "Socket open - servicing client = $client";
136 $cqservice->_serviceClient ($client);
137 debug "Returned from servicing client";
142 my $announcement = "$FindBin::Script v$VERSION ";
143 $announcement .= $cqservice->multithreaded
145 : '(Singlethreaded)';
147 verbose $announcement;
149 if ($opts{daemon} and !get_debug and !defined $DB::OUT) {
150 print $DB::OUT "Debugging\n" if get_debug;
152 my ($logfile) = ($FindBin::Script =~ /(.*)\.pl$/);
154 $opts{logfile} ||= "$logfile.log";
156 $logfile = File::Spec->rel2abs ($opts{logfile});
158 verbose "Entering daemon mode (Server pid: $$ - logging to $logfile)";
160 if ($Config{perl} eq 'ratlperl') {
161 error "Unable to daemonize with cqperl", 1;
163 EnterDaemonMode $opts{logfile}, $opts{logfile};
167 delete $opts{daemon};
168 delete $opts{multithreaded};
170 verbose 'Starting Server';
171 $cqservice->startServer;
173 verbose 'Shutting down server';