-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.py
More file actions
executable file
·42 lines (30 loc) · 1.12 KB
/
deploy.py
File metadata and controls
executable file
·42 lines (30 loc) · 1.12 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
#!/usr/bin/env python
import os
import json
from dotenv import load_dotenv
def main() -> None:
load_dotenv()
username: str = os.environ.get("USER", "")
host: str = os.environ.get("HOST", "")
if not username or not host:
print("Please provide a username and host in the .env file.")
exit(1)
print(f"Deploying to {username}@{host}")
try:
with open("program.json") as f:
program: dict = json.load(f)
name: str = program["name"]
f.close()
except FileNotFoundError:
print("Please provide a program.json file.")
exit(1)
os.system(f"scp -r ./src {username}@{host}:/mojo/program/{name}/")
os.system(f"scp program.json {username}@{host}:/mojo/program/{name}/")
os.system(f"uv pip freeze > requirements.txt")
os.system(f"scp requirements.txt {username}@{host}:/mojo/program/{name}/")
# Restart the program
# os.system(
# f'ssh {username}@{host} "program:restart {program}"'
# ) # This kills all current ssh sessions. Need to find a better way to restart the program.
if __name__ == "__main__":
main()