-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
9384b23
commit 70a07d5
Showing
17 changed files
with
318 additions
and
187 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -95,3 +95,4 @@ venv.bak/ | |
**/dev-dist | ||
manager/db.sqlite3-journal | ||
manager/schema.yml | ||
staging |
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
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
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
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
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,25 @@ | ||
import logging | ||
|
||
from django.contrib.auth.models import User as AuthUser | ||
from django.core.exceptions import MiddlewareNotUsed | ||
|
||
from manager.models import CustomUser | ||
|
||
log = logging.getLogger("rich") | ||
|
||
|
||
class Generate: | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
self.generate_users() | ||
raise MiddlewareNotUsed("Generate is disabled after initial use.") | ||
|
||
def generate_users(self): | ||
if not CustomUser.objects.exists(): | ||
admin = AuthUser.objects.get(username="admin") | ||
self.admin_user = CustomUser(auth=admin, concurrent_jobs=20) | ||
self.admin_user.save() | ||
|
||
def __call__(self, request): | ||
response = self.get_response(request) | ||
return response |
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
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 |
---|---|---|
|
@@ -22,4 +22,4 @@ COPY . . | |
RUN pip install . | ||
ENV SMB_MOUNT_POINT=/mnt/smb | ||
|
||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
CMD amuman-node |
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
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,46 @@ | ||
import json | ||
import logging | ||
import os | ||
import random | ||
from pathlib import Path | ||
|
||
log = logging.getLogger("rich") | ||
|
||
|
||
class Config: | ||
def __init__(self): | ||
self.name: str | ||
self.password: str | ||
self.manager_domain: str | ||
self.read_config() | ||
|
||
def read_config(self): | ||
path = Path("/config/config.json") | ||
if path.exists(): | ||
with open(path) as f: | ||
data = json.load(f) | ||
self.name = data.get("name") | ||
self.password = data.get("password") | ||
self.manager_domain = data.get("manager_domain") | ||
log.debug( | ||
f"Config read from file: {self.name=}, {self.password=}, {self.manager_domain=}" | ||
) | ||
|
||
self.name = os.getenv("NODE_NAME", os.getenv("HOST", str(int(1e12)))) | ||
if self.password is None: | ||
self.password = str(random.randint(0, int(1e12))) | ||
self.manager_domain: str = os.getenv("MANAGER_DOMAIN", "localhost") | ||
self.write_config() | ||
log.debug(f"Config: {self.name=}, {self.password=}, {self.manager_domain=}") | ||
|
||
def write_config(self): | ||
path = Path("/config/config.json") | ||
config = { | ||
"name": self.name, | ||
"password": self.password, | ||
"manager_domain": self.manager_domain, | ||
} | ||
# create the directory if it doesn't exist | ||
path.parent.mkdir(parents=True, exist_ok=True) | ||
with open(path, "w") as f: | ||
json.dump(config, f, indent=4) |
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
Oops, something went wrong.