forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_repos.pl
executable file
·133 lines (105 loc) · 3.36 KB
/
start_repos.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
# -*- perl -*-
use Env (ACE_ROOT);
use Env (DDS_ROOT);
use lib "$ACE_ROOT/bin";
use lib "$DDS_ROOT/bin";
use PerlDDS::Run_Test;
use Getopt::Long qw( :config bundling) ;
use Pod::Usage ;
my $status = 0;
#
# Basic options.
#
my $debug ;
my $man ;
my $help ;
my $verbose ;
#
# Specific options.
#
my $repoCount = 2;
my $debugFile;
my $transport;
########################################################################
#
# Process the command line.
#
GetOptions( "verbose!" => \$verbose,
"v" => \$verbose,
"help|?" => \$help,
"man" => \$man,
"debug|d=i" => \$debug,
"transport|t=i" => \$transport,
"repos|r=i" => \$repoCount,
"dfile|f=s" => \$debugFile,
) or pod2usage( 0) ;
pod2usage( 1) if $help ;
pod2usage( -verbose => 2) if $man ;
print "Debug==$debug\n" if $debug and $verbose;
print "TransportDebug==$transport\n" if $transport and $verbose;
print "Repos==$repoCount\n" if $verbose;
my @repo_ior;
my @repo_ini;
my @repo_port;
my @repo_endpoint;
for my $index ( 1 .. $repoCount) {
$repo_ior[ $index - 1] = PerlACE::LocalFile( "repo" . $index . ".ior");
# $repo_ini[ $index - 1] = PerlACE::LocalFile( "repo" . $index . "-federation.ini");
$repo_port[ $index - 1] = PerlACE::random_port();
$repo_endpoint[ $index - 1] = "iiop://localhost:" . $repo_port[ $index - 1];
print "Processing repository $index information.\n" if $debug;
}
# Clean out any left overs from a previous run.
unlink @repo_ior;
unlink $debugFile if $debugFile;
# Configure the repositories.
my @REPO;
my $repoDebug;
my $transportDebug;
$repoDebug = $debug if $debug;
$transportDebug = $transport if $transport;
my $verboseDebug;
$verboseDebug = "-ORBVerboseLogging 1 " if $verbose;
my $repoOpts = "";
$repoOpts .= $verboseDebug if $verboseDebug;
$repoOpts .= "-DCPSDebugLevel $repoDebug " if $repoDebug;
$repoOpts .= "-DCPSTransportDebugLevel $transportDebug " if $transportDebug;
$repoOpts .= "-ORBLogFile $debugFile " if ($repoDebug or $transportDebug) and $debugFile;
my @repoArgs;
for my $index ( 1 .. $repoCount) {
$repoArgs[ $index - 1] .= "$repoOpts -ORBListenEndpoints " . $repo_endpoint[ $index - 1] . " ";
$repoArgs[ $index - 1] .= "-o " . $repo_ior[ $index - 1] . " ";
$REPO[ $index - 1] = PerlDDS::create_process(
"$ENV{DDS_ROOT}/bin/DCPSInfoRepo", $repoArgs[ $index - 1]
);
print "Established repository $index.\n" if $debug;
}
# Fire up the repositories.
for my $index ( 1 .. $repoCount) {
print "\nREPOSITORY $index\n";
print $REPO[ $index - 1]->CommandLine() . "\n";
$REPO[ $index - 1]->Spawn();
if( PerlACE::waitforfile_timed( $repo_ior[ $index - 1], 30) == -1) {
print STDERR "ERROR: waiting for repository $index IOR file\n";
for my $inner (1 .. $index) {
$REPO[ $inner - 1]->Kill ();
}
exit 1;
}
}
print STDERR "Terminate the repositories[y]? ";
my $discard = <STDIN>;
# Terminate the repositories.
for my $index ( 1 .. $repoCount) {
print "\nStopping repository $index\n";
$status = $REPO[ $index - 1]->TerminateWaitKill(5);
if( $status != 0) {
print STDERR "ERROR: Repository $index returned $status\n";
}
}
# Clean up.
unlink @repo_ior;
exit $status;