From 2d7d1f992ab2713096f3dc88ad98a57f1d2393f9 Mon Sep 17 00:00:00 2001 From: youhuo Date: Thu, 18 Aug 2022 18:15:07 +0800 Subject: [PATCH] fix: system environment --- .gitignore | 1 - Dockerfile | 4 +++- app/conf.py | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 808746a..73b9e82 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,6 @@ Pipfile.lock .Python build/ develop-eggs/ -dist/ downloads/ eggs/ .eggs/ diff --git a/Dockerfile b/Dockerfile index 3cfd0cb..2bf8617 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,6 @@ RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN pip3 install -r /root/requirements.txt -i https://mirrors.aliyun.com/pypi/simple -CMD ["python3", "/root/app.py"] +WORKDIR /root + +CMD ["python3", "app.py"] diff --git a/app/conf.py b/app/conf.py index 40f01b0..02f0c86 100644 --- a/app/conf.py +++ b/app/conf.py @@ -12,8 +12,7 @@ class SanicConf(object): def init_app(self, app, env=None, group=None): self.config = None data = self.get_conf('app.properties') - app.config.update(data) - app.config.update(os.environ) + self.update_environ(data, os.environ) self.config = app.config def get_conf(self, file_name): @@ -35,6 +34,10 @@ class SanicConf(object): conf_dict[key.upper()] = self.string_to_other(value) return conf_dict + def update_environ(self, data, environs): + for key, value in environs.items(): + data[key.upper()] = value + def string_to_other(self, data): try: return int(data) -- Gitee