MT#12547 Remove hardcoded port 42042 from tt2-wrapper/tt2-daemon

We will use first free port instead which will be stored into
/var/run/ngcpcfg.port file while tt2-daemon is up and running.

Change-Id: I1a918f865d87863eef7d34be8abd1032282220b8
(cherry picked from commit e35944e2b5)
mr3.8.2
Alexander Lutay 11 years ago
parent 7b242408ad
commit 433e64fe9f

@ -31,7 +31,6 @@ sub get_server_port {
my $server = IO::Socket::INET->new(
'Proto' => 'tcp',
'LocalAddr' => 'localhost',
'LocalPort' => 42042,
'Listen' => SOMAXCONN,
'Reuse' => 1,
);
@ -39,6 +38,10 @@ sub get_server_port {
binmode $server => ":encoding(utf8)";
open (my $PORTFILE, '>', '/var/run/ngcpcfg.port');
print $PORTFILE $server->sockport();
close ($PORTFILE);
return $server;
}

@ -1,5 +1,17 @@
#!/bin/bash
echo "$@" | netcat localhost 42042
if [ -r /var/run/ngcpcfg.port ] ; then
port=$(cat /var/run/ngcpcfg.port)
else
echo "ERROR: Couldn't read file /var/run/ngcpcfg.port" >&2
exit 1
fi
if ! [[ $port =~ [0-9]+ ]] ; then
echo "ERROR: Wrong ngcpcfg tt2-daemon port: $port" >&2
exit 1
fi
echo "$@" | netcat localhost "$port"
exit $?

@ -54,6 +54,7 @@ done
# Kill all previous started tt2-daemon Perl processes if they were not stopped properly
killall tt2-daemon 2>/dev/null || true
rm -f /var/run/ngcpcfg.port
# Start new tt2-daemon Perl process
${HELPER}/tt2-daemon
@ -155,6 +156,7 @@ fi
# Kill all previous started tt2-daemon Perl processes
killall tt2-daemon 2>/dev/null || true
rm -f /var/run/ngcpcfg.port
exit "$RC"

Loading…
Cancel
Save