Permalink
Browse files

global variable for `_DAEMON_NAME`, better name for .log and .pid files

  • Loading branch information...
stnbu committed Sep 8, 2018
1 parent 395450d commit 5fde2697c4ecc0c6cbdcf8f724974bf27d201d7a
Showing with 7 additions and 4 deletions.
  1. +3 −0 coincharts/__init__.py
  2. +3 −3 coincharts/daemonize.py
  3. +1 −1 setup.py
@@ -0,0 +1,3 @@
# this is used in multiple places. Here seems like a good place for it.
_DAEMON_NAME = 'coincharts-daemon'
@@ -24,7 +24,7 @@
# We're replacing the module with a dict. Importing the file shouldn't result in reading from disk, etc. That's why.
config = config.get_config()
from coincharts import logger
from coincharts import logger, _DAEMON_NAME
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
@@ -144,7 +144,7 @@ def update(self):
def worker(dir_path, daemonize=True):
fh = logging.FileHandler(os.path.join(dir_path, 'logs'))
fh = logging.FileHandler(os.path.join(dir_path, '{}.log'.format(_DAEMON_NAME)))
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
fh.setLevel(logging.DEBUG)
@@ -195,7 +195,7 @@ def exception_handler(type_, value, tb):
logger.debug('starting daemon {} using path {}'.format(script_name, dir_path))
if daemonize:
pid_file = os.path.join(dir_path, script_basename + '.pid')
pid_file = os.path.join(dir_path, script_basename + '{}.pid'.format(_DAEMON_NAME))
with daemon.DaemonContext(
working_directory=dir_path,
pidfile=daemon.pidfile.PIDLockFile(pid_file),
@@ -24,6 +24,6 @@ def read(file):
provides=[name],
packages=[name],
entry_points = {
'console_scripts': ['coincharts-daemon=coincharts.daemonize:main'],
'console_scripts': ['{}=coincharts.daemonize:main'.format(coincharts._DAEMON_NAME)],
}
)

0 comments on commit 5fde269

Please sign in to comment.