refs #529 remove useless ogAdmClient.py
parent
5482d25116
commit
97246759c1
|
@ -1,114 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2014 Virtual Cable S.L.
|
||||
# Copyright (c) 2024 Qindel Formación y Servicios S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
@author: Natalia Serrano, nserrano at qindel dot com
|
||||
"""
|
||||
|
||||
|
||||
from opengnsys.service import CommonService
|
||||
from opengnsys.log import logger
|
||||
from opengnsys.linux.daemon import Daemon
|
||||
|
||||
import sys
|
||||
import signal
|
||||
import json
|
||||
|
||||
try:
|
||||
from prctl import set_proctitle # @UnresolvedImport
|
||||
except ImportError:
|
||||
def set_proctitle(_):
|
||||
pass
|
||||
|
||||
|
||||
class OGAgentSvc(Daemon, CommonService):
|
||||
def __init__(self, args=None):
|
||||
Daemon.__init__(self, '/var/run/opengnsys-agent.pid')
|
||||
CommonService.__init__(self)
|
||||
|
||||
def run(self):
|
||||
logger.debug('** Running Daemon **')
|
||||
set_proctitle('ogAdmClient')
|
||||
|
||||
self.initialize()
|
||||
|
||||
# Call modules initialization
|
||||
# They are called in sequence, no threading is done at this point, so ensure modules onActivate always returns
|
||||
|
||||
# *********************
|
||||
# * Main Service loop *
|
||||
# *********************
|
||||
# Counter used to check ip changes only once every 10 seconds, for
|
||||
# example
|
||||
try:
|
||||
while self.isAlive:
|
||||
self.doWait(1000)
|
||||
except (KeyboardInterrupt, SystemExit) as e:
|
||||
logger.error('Requested exit of main loop')
|
||||
except Exception as e:
|
||||
logger.exception()
|
||||
logger.error('Caught exception on main loop: {}'.format(e))
|
||||
|
||||
self.terminate()
|
||||
self.notifyStop()
|
||||
|
||||
def signal_handler(self, signal, frame):
|
||||
self.isAlive = False
|
||||
sys.stderr.write("signal handler: {}".format(signal))
|
||||
|
||||
|
||||
def usage():
|
||||
sys.stderr.write("usage: {} start|stop|restart|fg\n".format(sys.argv[0]))
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger.setLevel('DEBUG')
|
||||
|
||||
logger.debug('Executing actor')
|
||||
daemon = OGAgentSvc()
|
||||
|
||||
signal.signal(signal.SIGTERM, daemon.signal_handler)
|
||||
signal.signal(signal.SIGINT, daemon.signal_handler)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
if 'start' == sys.argv[1]:
|
||||
daemon.start()
|
||||
elif 'stop' == sys.argv[1]:
|
||||
daemon.stop()
|
||||
elif 'restart' == sys.argv[1]:
|
||||
daemon.restart()
|
||||
elif 'fg' == sys.argv[1]:
|
||||
daemon.run()
|
||||
else:
|
||||
usage()
|
||||
sys.exit(0)
|
||||
else:
|
||||
usage()
|
Loading…
Reference in New Issue