forked from apache/openserverless-admin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-port-forwards.sh
More file actions
executable file
·60 lines (51 loc) · 2.29 KB
/
start-port-forwards.sh
File metadata and controls
executable file
·60 lines (51 loc) · 2.29 KB
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
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
set -e
# Log start time for debugging
echo "$(date): Starting port forwards..." >> /tmp/pf-start.log
# Clean up any existing port forwards first
pkill -f 'kubectl port-forward -n nuvolaris registry-0' 2>/dev/null || true
pkill -f 'kubectl -n nuvolaris port-forward couchdb-0' 2>/dev/null || true
rm -f /tmp/pf-registry.pid /tmp/pf-couchdb.pid /tmp/pf-registry.log /tmp/pf-couchdb.log
sleep 1
# Start port forwards in background with nohup to detach from terminal
nohup kubectl port-forward -n nuvolaris registry-0 5000:5000 > /tmp/pf-registry.log 2>&1 &
REGISTRY_PID=$!
echo $REGISTRY_PID > /tmp/pf-registry.pid
echo "$(date): Registry PID: $REGISTRY_PID" >> /tmp/pf-start.log
nohup kubectl -n nuvolaris port-forward couchdb-0 5984:5984 > /tmp/pf-couchdb.log 2>&1 &
COUCHDB_PID=$!
echo $COUCHDB_PID > /tmp/pf-couchdb.pid
echo "$(date): CouchDB PID: $COUCHDB_PID" >> /tmp/pf-start.log
# Disown the processes so they don't get killed when the script exits
disown -a
# Wait a moment for port forwards to establish
sleep 2
# Verify processes are still running
if ps -p $REGISTRY_PID > /dev/null 2>&1; then
echo "$(date): Registry port-forward is running" >> /tmp/pf-start.log
else
echo "$(date): WARNING: Registry port-forward died!" >> /tmp/pf-start.log
fi
if ps -p $COUCHDB_PID > /dev/null 2>&1; then
echo "$(date): CouchDB port-forward is running" >> /tmp/pf-start.log
else
echo "$(date): WARNING: CouchDB port-forward died!" >> /tmp/pf-start.log
fi
echo "Port forwards started: registry=$REGISTRY_PID, couchdb=$COUCHDB_PID"