def _start(config, args): ''' Start the cache server. ''' daemon = VmCacheDaemon(config, args) # Configure daemon if not daemon.configure(): _log.critical('{}: configuration failed'.format(daemon.name)) sys.exit(1) rc = daemon.start(args.foreground) if rc == errno.EINVAL: msg = '{}: error in config file'.format(daemon.name) elif rc == errno.EEXIST: msg = '{} is already running'.format(daemon.name) elif rc == errno.ESRCH: msg = ''' {daemon} does not appear to be running but the lock file {pidfile} exists. '''.format(daemon=daemon.name, pidfile=daemon.pidfile.path) else: msg = '{} returned unexpectedly with rc={}'.format(daemon.name, rc) sys.stderr.write(msg.strip()) sys.stderr.write('\n') sys.exit(1)
def _stop(config, args): ''' Stop the cache server. ''' daemon = VmCacheDaemon(config, args) daemon.stop()