allow server.run without python-daemon

is python-deamon is not installed, secop-server should work
without '-d' option.

Change-Id: I2d64379a7612931c55f1d9cdbdb2cb424453c675
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21909
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2019-11-27 08:56:49 +01:00
parent e953b53963
commit ca8b07496f

View File

@ -29,16 +29,19 @@ import threading
import configparser
from collections import OrderedDict
from daemon import DaemonContext
try:
from daemon import DaemonContext
try:
import daemon.pidlockfile as pidlockfile
except ImportError:
import daemon.pidfile as pidlockfile
except ImportError:
DaemonContext = None
from secop.errors import ConfigError
from secop.lib import formatException, get_class, getGeneralConfig
from secop.modules import Attached
try:
import daemon.pidlockfile as pidlockfile
except ImportError:
import daemon.pidfile as pidlockfile
class Server:
@ -75,6 +78,8 @@ class Server:
self._interface = None
def start(self):
if not DaemonContext:
raise ConfigError('can not daemonize, as python-daemon is not installed')
piddir = os.path.dirname(self._pidfile)
if not os.path.isdir(piddir):
os.makedirs(piddir)