Removed /usr/local from CDPATH
[clearscm.git] / CCDB / ccdbservice.pl
1 #!/usr/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: ccdbservice.pl,v $
6
7 ClearCase DataBase Service: Respond to requests for Clearcase metadata from
8 CCDB.
9
10 =head1 VERSION
11
12 =over
13
14 =item Author
15
16 Andrew DeFaria <Andrew@ClearSCM.com>
17
18 =item Revision
19
20 $Revision: 1.1 $
21
22 =item Created:
23
24 Fri Mar 11 17:45:57 PST 2011
25
26 =item Modified:
27
28 $Date: 2011/03/22 19:18:04 $
29
30 =back
31
32 =head1 SYNOPSIS
33
34  Usage ccdbservice.pl: [-u|sage] [-ve|rbose] [-de|bug] 
35                        [-da|emon] [-m|ultithreaded] [-p|idfile]
36                        [-l|ogfile <logfile>]
37
38  Where:
39    -u|sage:         Displays usage
40  
41    -ve|rbose:       Be verbose
42    -de|bug:         Output debug messages
43    
44    -da|emon:        Run in daemon mode. Use -nod|aemon to run in foreground
45                     (Default: -daemon)
46    -m|ultithreaded: Multithread requests. Use -nom|ultithreaded to single
47                     thread request handline (Default: -multithreaded)
48    -p|idfile:       File to be created with the pid written to it (Default: 
49                     ccddservice.pid). Note: pidfile is only written if -daemon
50                     is specified.
51    -l|ogfile:       Specify alternative logfile name. Note that .log will be 
52                     appended. (Default: ccdbservice.log).
53                     
54 Note: Certain options can be set in ../etc/ccdbserver.conf. See ccdbserver.conf
55 for more info.
56    
57 =head1 DESCRIPTION
58
59 This script normally runs as a daemon and accepts requests from other hosts to
60 retrieve Clearcase metadata from CCDB.
61
62 =cut
63
64 use strict;
65 use warnings;
66
67 use Getopt::Long;
68 use FindBin;
69
70 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
71
72 use CCDB;
73 use CCDBService;
74 use Display;
75 use Utils;
76
77 my $VERSION  = '$Revision: 1.1 $';
78   ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
79
80 # Extract relative path and basename from script name.
81 my $me = $FindBin::Script;
82   
83 # Remove .pl for Perl scripts that have that extension
84 $me =~ s/\.pl$//;
85   
86 my $pidfile = 
87   "$CCDBService::OPTS{CCDB_RUNDIR}/$me.pid";
88 my $logfile = 
89   "$CCDBService::OPTS{CCDB_LOGDIR}/$me.log";
90   
91 # Main
92 my $multithreaded = $CCDBService::OPTS{CCDB_MULTITHREADED};
93 my $daemon        = 1;
94
95 GetOptions (
96   'usage'           => sub { Usage },
97   'verbose'         => sub { set_verbose },
98   'debug'           => sub { set_debug },
99   'daemon!'         => \$daemon,
100   'multithreaded!'  => \$multithreaded,
101   'pidfile=s'       => \$pidfile,
102   'logfile=s'       => \$logfile,
103 ) or Usage "Invalid parameter";
104
105 Usage 'Extraneous options: ' . join ' ', @ARGV
106   if @ARGV;
107
108 my $CCDBService = CCDBService->new;
109
110 $CCDBService->setMultithreaded ($multithreaded);
111
112 EnterDaemonMode $logfile, $logfile, $pidfile
113   if $daemon;
114   
115 display "$FindBin::Script V$VERSION started at " . localtime;
116
117 $CCDBService->startServer;
118
119 verbose "Server running";
120
121 =pod
122
123 =head1 CONFIGURATION AND ENVIRONMENT
124
125 DEBUG: If set then $debug is set to this level.
126
127 VERBOSE: If set then $verbose is set to this level.
128
129 TRACE: If set then $trace is set to this level.
130
131 =head1 DEPENDENCIES
132
133 =head2 Perl Modules
134
135 L<FindBin>
136
137 L<Getopt::Long|Getopt::Long>
138
139 =head2 ClearSCM Perl Modules
140
141 =begin man 
142
143  Clearexec
144  Display
145  Utils
146
147 =end man
148
149 =begin html
150
151 <blockquote>
152 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearexec.pm">Clearexec</a><br>
153 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
154 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
155 </blockquote>
156
157 =end html
158
159 =head1 BUGS AND LIMITATIONS
160
161 There are no known bugs in this script
162
163 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
164
165 =head1 LICENSE AND COPYRIGHT
166
167 Copyright (c) 2010, Tellabs, Inc. All rights reserved.
168
169 =cut
170