-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add whisper to autoscaler #652
base: main
Are you sure you want to change the base?
Changes from 1 commit
86c0812
475f562
b3146a9
d6cac1e
5dfedc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,7 @@ | |
# docker pull most recent running version of skynet and whisper | ||
- { role: "gpu-docker-pull", tags: "gpu-docker", gpu_docker_type: "skynet" } | ||
- { role: "gpu-docker-pull", tags: "gpu-docker", gpu_docker_type: "whisper" } | ||
- { role: "streaming-whisper", tags: "gpu-docker", gpu_docker_type: "whisper" } | ||
- { role: "autoscaler-sidecar", tags: "autoscaler-sidecar", | ||
autoscaler_instance_type: "streaming-whisper", autoscaler_install_flag: true, autoscaler_configure_flag: false, jitsi_autoscaler_sidecar: true} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a shared image for both skynet ande whisper, so we wouldn't want to set the instance type here. |
||
- { role: "clean-system", tags: "clean-system, build" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Sets the server to drain mode and waits for all the connections to be closed before exiting | ||
# with code 0 (clean shutdown). If the connections are not closed within the specified time, | ||
# the script will exit with code 1 (dirty) and the autoscaler will shut down the instance anyway. | ||
|
||
# It takes two parameters: WAIT_SECONDS and STATE_URL | ||
# WAIT_SECONDS: Seconds to wait for the server to enter drain mode and close all connections. | ||
# Defaults to 100. | ||
# STATE_URL: The URL of the whisper state endpoint. Defaults to http://localhost:8003/state. | ||
|
||
# Example usage: ./shutdown_script.sh 100 http://localhost:8003/state | ||
|
||
|
||
WAIT_SECONDS=100 | ||
STATE_URL="http://localhost:8003/state" | ||
|
||
[[ -z $1 ]] && echo "Parameter WAIT_SECONDS not set, using default $WAIT_SECONDS" || WAIT_SECONDS=$1 | ||
[[ -z $2 ]] && echo "Parameter STATE_URL not set, using default $STATE_URL" || STATE_URL=$2 | ||
|
||
echo "Waiting for $WAIT_SECONDS seconds for the server to enter drain mode and close all connections." | ||
|
||
START_TIME=$(date +%s) | ||
|
||
while true; do | ||
RESPONSE=$(curl -s $STATE_URL) | ||
WHISPER_STATE=$(echo $RESPONSE | jq -r '.state') | ||
ACTIVE_CONNECTIONS=$(echo $RESPONSE | jq -r '.connections') | ||
if [[ $WHISPER_STATE != "drain" ]]; then | ||
echo "Setting server in drain mode." | ||
curl -s -XPOST $STATE_URL -d '{"state": "drain"}' | jq -r '.request_status' | ||
else | ||
echo "Server is in drain mode. Waiting for $ACTIVE_CONNECTIONS connections to be closed before shutting down" | ||
if [[ $ACTIVE_CONNECTIONS -eq 0 ]]; then | ||
echo "All connections are closed. Shutting down the instance." | ||
exit 0 | ||
fi | ||
fi | ||
CURRENT_TIME=$(date +%s) | ||
ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) | ||
if [[ $ELAPSED_TIME -gt $WAIT_SECONDS ]]; then | ||
break | ||
fi | ||
sleep 2 | ||
done | ||
|
||
echo "Server did not close all connections within $WAIT_SECONDS seconds. Shutting down anyway." | ||
exit 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- name: Install dependencies | ||
ansible.builtin.package: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine to include these, but just FYI they should both be already installed in the base image so this will be a no-op. |
||
name: | ||
- jq | ||
- curl | ||
state: latest | ||
|
||
- name: Copy graceful shutdown script | ||
ansible.builtin.copy: | ||
src: streaming-whisper-graceful-shutdown.sh | ||
dest: /usr/local/bin/streaming-whisper-graceful-shutdown.sh | ||
mode: 0755 | ||
owner: root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This role is already included in the base image that GPU comes from, so no need to install it here.