-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (24 loc) · 753 Bytes
/
main.py
File metadata and controls
31 lines (24 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
from pathlib import Path
from loguru import logger
try:
from picbed.singleton import cleanup_singleton, initSingleton
shm, has_running_instance = initSingleton()
if has_running_instance:
sys.exit(0)
from picbed.utils import setup_stdout
setup_stdout()
import picbed.app
picbed.app.main()
cleanup_singleton(shm)
logger.info("PicBed Exited.")
except Exception as e:
try:
from picbed.utils import appdir
logdir = appdir() / "logs"
except Exception:
logdir = Path("logs")
logger.add(logdir / "picbed-critical.log", rotation="10 MB", retention=10, enqueue=True)
logger.exception(e)
logger.info(f"PicBed Exited with exception. {e}")
sys.exit(0)