Skip to content

Commit 805ff36

Browse files
Leonid Ryzhykryzhyk
authored andcommitted
Fixup demo script to run manager in foreground.
The pipeline manager no longer runs as a background daemon process. This broke the `demo.sh` script, which used to wait for the manager process to return control to the script before instantiating the demos. We change the demo flow to run the manager in the foreground and spawn processes to crate demo pipelines in the background. We also change `Makefile.toml` to run the manager in the background. Signed-off-by: Leonid Ryzhyk <leonid@feldera.com>
1 parent 81ff02b commit 805ff36

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

crates/pipeline_manager/Makefile.toml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,26 @@ pip3 install websockets
2828

2929
[tasks.start_manager]
3030
script = '''
31-
../../scripts/start_manager.sh
31+
old_manager_pid=$(pgrep "pipeline-mana" || echo "")
32+
echo "Old manager: " $old_manager_pid
33+
if [ -n "$old_manager_pid" ]; then
34+
echo "Previous manager instance is running"
35+
exit 1
36+
fi
37+
../../scripts/start_manager.sh &
38+
manager_pid=$!
39+
while true; do
40+
if curl --output /dev/null --silent --head --fail http://localhost:8080; then
41+
echo "Pipeline manager is up and running"
42+
break
43+
else
44+
if ! ps -p $manager_pid > /dev/null; then
45+
echo "Manager process has terminated unexpectedly"
46+
exit 1
47+
fi
48+
sleep 1
49+
fi
50+
done
3251
'''
3352

3453
[tasks.python_api_test]

demo/demo.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,31 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
44
ROOT="${THIS_DIR}/../"
55
SERVER_DIR="${ROOT}/crates/pipeline_manager/"
66

7-
set -e
8-
97
export REDPANDA_BROKERS=localhost:9092
108

11-
docker kill redpanda || true
12-
docker rm redpanda || true
13-
docker run --name redpanda -p 9092:9092 --rm -itd docker.redpanda.com/vectorized/redpanda:v23.1.13
9+
docker kill redpanda
10+
docker rm redpanda
11+
docker run --name redpanda -p 9092:9092 --rm -itd docker.redpanda.com/vectorized/redpanda:v23.2.3 || { echo 'Failed to start RedPanda container' ; exit 1; }
12+
13+
# Kill the entire process group (including processes spawned by prepare_demo_data.sh) on shutdown.
14+
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
15+
16+
(
17+
# wait for the manager
18+
while true; do
19+
if curl --output /dev/null --silent --head --fail http://localhost:8080; then
20+
echo "Pipeline manager is up and running"
21+
break
22+
else
23+
sleep 1
24+
fi
25+
done
26+
DBSP_MANAGER="http://localhost:8080" ${THIS_DIR}/create_demo_projects.sh
27+
DBSP_MANAGER="http://localhost:8080" ${THIS_DIR}/prepare_demo_data.sh
28+
) &
29+
30+
prepare_subshell_pid=$!
1431

1532
${ROOT}/scripts/start_manager.sh ${THIS_DIR}/pipeline_data
1633

17-
DBSP_MANAGER="http://localhost:8080" ${THIS_DIR}/create_demo_projects.sh
18-
DBSP_MANAGER="http://localhost:8080" ${THIS_DIR}/prepare_demo_data.sh
34+
# kill -9 $prepare_subshell_pid

demo/prepare_demo_data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ do
1717
# TimeSeriesEnrich data is the same as we loaded in SimpleSelect
1818
if [ "$project_name" != "demo01-TimeSeriesEnrich" ]
1919
then
20-
python3 "${project_dir}/run.py" --dbsp_url ${DBSP_MANAGER} --actions prepare
20+
python3 "${project_dir}/run.py" --dbsp_url ${DBSP_MANAGER} --actions prepare &
2121
fi
2222
done

scripts/start_manager.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ else
3434
DB_CONNECTION_STRING="--db-connection-string=postgresql://${PGUSER}@localhost"
3535
fi
3636

37+
manager_pid=$(pgrep "pipeline-mana" || echo "")
38+
39+
if [ -n "$manager_pid" ]; then
40+
echo "Previous manager instance is running"
41+
exit 1
42+
fi
43+
3744
cd "${MANAGER_DIR}" && ~/.cargo/bin/cargo build $RUST_BUILD_PROFILE $PG_EMBED
3845
cd "${MANAGER_DIR}" && ~/.cargo/bin/cargo run --bin pipeline-manager $RUST_BUILD_PROFILE $PG_EMBED -- \
3946
--bind-address="${BIND_ADDRESS}" \

0 commit comments

Comments
 (0)