izuemon commited on
Commit
3a4a02a
Β·
verified Β·
1 Parent(s): 600f3fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -24
app.py CHANGED
@@ -6,30 +6,33 @@ import sys
6
 
7
  app = Flask(__name__)
8
 
9
- watcher_process = None
10
- dmsender_process = None
11
-
12
- def start_watcher():
13
- global watcher_process, dmsender_process
14
-
15
- if watcher_process is None or watcher_process.poll() is not None:
16
- watcher_process = subprocess.Popen(
17
- [sys.executable, "watcher.py"],
18
- stdout=sys.stdout,
19
- stderr=sys.stderr,
20
- env=os.environ,
21
- )
22
- print("watcher.py γ‚’θ΅·ε‹•γ—γΎγ—γŸ")
23
-
24
- if dmsender_process is None or dmsender_process.poll() is not None:
25
- dmsender_process = subprocess.Popen(
26
- [sys.executable, "news.py"],
27
- stdout=sys.stdout,
28
- stderr=sys.stderr,
29
- env=os.environ,
30
- )
31
- print("news.py γ‚’θ΅·ε‹•γ—γΎγ—γŸ")
32
-
 
 
 
33
 
34
  #----------
35
 
 
6
 
7
  app = Flask(__name__)
8
 
9
+ processes = {
10
+ "watcher": {
11
+ "file": "watcher.py",
12
+ "proc": None,
13
+ },
14
+ "news": {
15
+ "file": "news.py",
16
+ "proc": None,
17
+ },
18
+ "chatgpt": {
19
+ "file": "chatgpt.py",
20
+ "proc": None,
21
+ },
22
+ }
23
+
24
+ def start_processes():
25
+ for name, info in processes.items():
26
+ proc = info["proc"]
27
+
28
+ if proc is None or proc.poll() is not None:
29
+ info["proc"] = subprocess.Popen(
30
+ [sys.executable, info["file"]],
31
+ stdout=sys.stdout,
32
+ stderr=sys.stderr,
33
+ env=os.environ,
34
+ )
35
+ print(f"{info['file']} γ‚’θ΅·ε‹•γ—γΎγ—γŸ")
36
 
37
  #----------
38