| 199 | self.chdir() |
| 200 | |
| 201 | def run(self): |
| 202 | if self.cfg.print_config: |
| 203 | print(self.cfg) |
| 204 | |
| 205 | if self.cfg.print_config or self.cfg.check_config: |
| 206 | try: |
| 207 | self.load() |
| 208 | except Exception: |
| 209 | msg = "\nError while loading the application:\n" |
| 210 | print(msg, file=sys.stderr) |
| 211 | traceback.print_exc() |
| 212 | sys.stderr.flush() |
| 213 | sys.exit(1) |
| 214 | sys.exit(0) |
| 215 | |
| 216 | if self.cfg.spew: |
| 217 | debug.spew() |
| 218 | |
| 219 | if self.cfg.daemon: |
| 220 | if os.environ.get('NOTIFY_SOCKET'): |
| 221 | msg = "Warning: you shouldn't specify `daemon = True`" \ |
| 222 | " when launching by systemd with `Type = notify`" |
| 223 | print(msg, file=sys.stderr, flush=True) |
| 224 | |
| 225 | util.daemonize(self.cfg.enable_stdio_inheritance) |
| 226 | |
| 227 | # set python paths |
| 228 | if self.cfg.pythonpath: |
| 229 | paths = self.cfg.pythonpath.split(",") |
| 230 | for path in paths: |
| 231 | pythonpath = os.path.abspath(path) |
| 232 | if pythonpath not in sys.path: |
| 233 | sys.path.insert(0, pythonpath) |
| 234 | |
| 235 | super().run() |