Fix path detection.
Change-Id: If76969e6c753596fff885fdb021ba53b1537c945
This commit is contained in:
@ -36,6 +36,20 @@ import unicodedata
|
||||
from os import path
|
||||
|
||||
|
||||
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
|
||||
|
||||
CONFIG = {
|
||||
'piddir': os.path.join(repodir, 'pid'),
|
||||
'logdir': os.path.join(repodir, 'log'),
|
||||
'confdir': os.path.join(repodir, 'etc'),
|
||||
} if os.path.exists(os.path.join(repodir, '.git')) else {
|
||||
'piddir': '/var/run/secop',
|
||||
'logdir': '/var/log/secop',
|
||||
'confdir': '/etc/secop',
|
||||
}
|
||||
|
||||
|
||||
|
||||
class lazy_property(object):
|
||||
"""A property that calculates its value only once."""
|
||||
|
||||
@ -223,10 +237,5 @@ def getfqdn(name=''):
|
||||
return socket.getfqdn(name)
|
||||
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# print "minimal testing: lib"
|
||||
# d = attrdict(a=1, b=2)
|
||||
# _ = d.a + d['b']
|
||||
# d.c = 9
|
||||
# d['d'] = 'c'
|
||||
# assert d[d.d] == 9
|
||||
def getGeneralConfig():
|
||||
return CONFIG
|
||||
|
@ -35,24 +35,22 @@ try:
|
||||
except ImportError:
|
||||
import daemon.pidfile as pidlockfile
|
||||
|
||||
from secop.lib import get_class, formatException
|
||||
from secop.lib import get_class, formatException, getGeneralConfig
|
||||
from secop.protocol.dispatcher import Dispatcher
|
||||
from secop.protocol.interface import INTERFACES
|
||||
#from secop.protocol.encoding import ENCODERS
|
||||
#from secop.protocol.framing import FRAMERS
|
||||
from secop.errors import ConfigError
|
||||
|
||||
|
||||
class Server(object):
|
||||
|
||||
def __init__(self, name, workdir, parentLogger=None):
|
||||
def __init__(self, name, parentLogger=None):
|
||||
self._name = name
|
||||
self._workdir = workdir
|
||||
|
||||
self.log = parentLogger.getChild(name, True)
|
||||
|
||||
self._pidfile = os.path.join(workdir, 'pid', name + '.pid')
|
||||
self._cfgfile = os.path.join(workdir, 'etc', name + '.cfg')
|
||||
cfg = getGeneralConfig()
|
||||
self._pidfile = os.path.join(cfg['piddir'], name + '.pid')
|
||||
self._cfgfile = os.path.join(cfg['confdir'], name + '.cfg')
|
||||
|
||||
self._dispatcher = None
|
||||
self._interface = None
|
||||
@ -67,7 +65,6 @@ class Server(object):
|
||||
self.log.error('Pidfile already exists. Exiting')
|
||||
|
||||
with DaemonContext(
|
||||
working_directory=self._workdir,
|
||||
pidfile=pidfile,
|
||||
files_preserve=self.log.getLogfileStreams()):
|
||||
self.run()
|
||||
|
Reference in New Issue
Block a user