-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
134 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
cleanup() { | ||
echo "Stopping the LLM_SERVER_PID server..." | ||
kill $LLM_SERVER_PID | ||
wait $LLM_SERVER_PID 2>/dev/null | ||
echo "Stopped" | ||
} | ||
|
||
|
||
original_dir=$(pwd) | ||
|
||
# Change Directory to 'llm_server' and run the entrypoint script in the background | ||
cd llm_server | ||
./entrypoint.sh & | ||
LLM_SERVER_PID=$! | ||
cd "$original_dir" | ||
|
||
# Run the llm_autoupdate script | ||
python run_autoupdater.py --restart_script autoupdate_llm.sh --process_pid $LLM_SERVER_PID | ||
|
||
|
||
cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
import subprocess | ||
import time | ||
|
||
|
||
def should_update_local(local_tag, remote_tag): | ||
if remote_tag[0] == local_tag[0]: | ||
return remote_tag != local_tag | ||
return False | ||
|
||
|
||
def run_autoupdate(restart_script: str, process_pid: int): | ||
branch_name = subprocess.getoutput("git rev-parse --abbrev-ref HEAD") | ||
|
||
while True: | ||
local_tag = subprocess.getoutput("git describe --abbrev=0 --tags") | ||
os.system(f"git fetch origin {branch_name}") | ||
remote_tag = subprocess.getoutput( | ||
f"git describe --tags `git rev-list --tags=origin/{branch_name} --max-count=1`" | ||
) | ||
|
||
if should_update_local(local_tag, remote_tag): | ||
print("Local repo is not up-to-date. Updating...") | ||
reset_cmd = "git reset --hard " + remote_tag | ||
process = subprocess.Popen(reset_cmd.split(), stdout=subprocess.PIPE) | ||
output, error = process.communicate() | ||
|
||
if error: | ||
print("Error in updating:", error) | ||
else: | ||
print("Updated local repo to latest version: {}", format(remote_tag)) | ||
|
||
print("Running the autoupdate steps...") | ||
# Trigger shell script. Make sure this file path starts from root | ||
subprocess.run(["kill", f"{process_pid}"], shell=True) | ||
subprocess.run(["wait", f"{process_pid}", "2>/dev/null"], shell=True) | ||
subprocess.call([f"./{restart_script}"], shell=True) | ||
print("Finished running the autoupdate steps! Ready to go 😎") | ||
|
||
else: | ||
print("Repo is up-to-date.") | ||
|
||
time.sleep(60) | ||
|
||
|
||
if __name__ == "__main__": | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--restart_script", type=str) | ||
parser.add_argument("--process_pid", type=int) | ||
args = parser.parse_args() | ||
run_autoupdate( | ||
restart_script=args.restart_script, process_pid=args.process_pid | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.