def test_basic(): # check cfg cfg_path = os.path.join(BASE_DIR, 'tests', 'cfg_service.yml') os.environ['WDFWD_CFG'] = cfg_path cfg = get_config() appc = cfg['app'] assert appc['service']['name'] == 'wdfwd_test' # test service isntall with ChangeDir('wdfwd', 'test_dist'): cap_call('wdfwd_svc.exe install') # test start cap_call('wdfwd_svc.exe start') svc = get_service() assert svc is not None assert svc.Status == 'OK'
import time from datetime import datetime import traceback from croniter import croniter from wdfwd.get_config import get_config from wdfwd.tail import FileTailer, TableTailer, TailThread from wdfwd.util import ldebug, linfo, lerror, supress_boto3_log,\ iter_tail_info, TableTailInfo, FileTailInfo from wdfwd.sync import sync_file cfg = get_config() appc = cfg['app'] tailc = cfg.get('tailing') start_dt = datetime.now() schedule = appc['service'].get('schedule') cit = croniter(schedule, start_dt) if schedule else None next_dt = cit.get_next(datetime) if cit else None logcnt = 0 LOG_SYNC_CNT = 30 force_first_run = appc['service'].get('force_first_run', False) tail_threads = [] fsender = None def start_tailing(): linfo("start_tailing")
import traceback import win32service # NOQA import win32serviceutil # NOQA import win32event # NOQA import servicemanager # NOQA from wdfwd import app from wdfwd.get_config import get_config from wdfwd.util import ldebug, lerror, lheader, init_global_fsender from wdfwd.const import SVC_SLEEP_SEC cfg = get_config() scfg = cfg['app']['service'] lcfg = cfg['log'] if 'fluent' in lcfg: fhost = lcfg['fluent'][0] fport = lcfg['fluent'][1] init_global_fsender('wdfwd.main', fhost, fport) elif 'kinesis' in lcfg: kaccess_key = lcfg['kinesis']['access_key'] ksecret_key = lcfg['kinesis']['secret_key'] kregion = lcfg['kinesis']['region'] class WdFwdService(win32serviceutil.ServiceFramework): _svc_name_ = scfg['name'] _svc_display_name_ = scfg['caption'] def __init__(self, args):