|
22 | 22 | import os
|
23 | 23 | import signal
|
24 | 24 | from time import sleep
|
25 |
| -from .session import SESSION_DIR, DATA_DIR |
| 25 | +from .constants import SESSION_DIR, DATA_DIR, LOG_FOLDER, CONFIG_PATH, CONFIG_FILE, FILE_LOG, RUN_FOLDER, PID_FILE |
26 | 26 | from .handlers import CreateMessaging, StatusMessaging, RemoveMessaging, RankMessaging
|
27 |
| -from .utils import remove, default_val |
28 |
| -from .cloud import Cloud, LOG_FOLDER, CONFIG_PATH, CONFIG_FILE, FILE_LOG |
| 27 | +from .utils import remove, default_val, required_paths |
| 28 | +from .cloud import Cloud |
29 | 29 | from redis import Redis
|
30 | 30 | from redis.exceptions import ConnectionError
|
31 | 31 | import yaml
|
32 | 32 |
|
33 |
| -RUN_FOLDER = '/var/run/year4000/pycloud/' |
34 |
| -PID_FILE = RUN_FOLDER + 'pycloud.pid' |
35 |
| - |
36 | 33 |
|
37 | 34 | def start_daemon(nodes=None):
|
38 | 35 | """ Spins off a process that runs as a daemon """
|
@@ -77,7 +74,6 @@ def shutdown_daemon(*args):
|
77 | 74 | os.remove(PID_FILE)
|
78 | 75 | raise SystemExit('Terminating on signal number {0}'.format(args[0]))
|
79 | 76 |
|
80 |
| - |
81 | 77 | def main(nodes=None):
|
82 | 78 | """ Deploy all the needed threads """
|
83 | 79 | nodes = int(0 if nodes is None else nodes)
|
@@ -152,15 +148,6 @@ def daemon_thread(target, name=None):
|
152 | 148 | thread.start()
|
153 | 149 | return thread
|
154 | 150 |
|
155 |
| -def required_paths(): |
156 |
| - """ Make sure the needed folders exist """ |
157 |
| - for folder in (SESSION_DIR, DATA_DIR, LOG_FOLDER, CONFIG_PATH, RUN_FOLDER): |
158 |
| - if not os.path.exists(folder): |
159 |
| - try: |
160 |
| - os.makedirs(folder) |
161 |
| - finally: |
162 |
| - os.chmod(folder, 0o777) # hack fix for an existing bug |
163 |
| - |
164 | 151 |
|
165 | 152 | if __name__ == '__main__':
|
166 | 153 | _log = logging.getLogger('pycloud')
|
|
0 commit comments