#5 - Replace class khaganatHTTPServer by OpenNeLHTTPServer
This commit is contained in:
parent
00160cdf5c
commit
8d8f199037
7 changed files with 50 additions and 42 deletions
|
@ -217,7 +217,7 @@ class Certificate:
|
|||
'stateOrProvinceName_default = France\n'
|
||||
'localityName = Locality Name (eg, city)\n'
|
||||
'0.organizationName = Organization Name (eg, company)\n'
|
||||
'0.organizationName_default = Khanat\n'
|
||||
'0.organizationName_default = OpenNeL\n'
|
||||
'organizationalUnitName = Organizational '
|
||||
'Unit Name (eg, section)\n'
|
||||
'commonName = Common Name (e.g. server FQDN or YOUR name)\n'
|
||||
|
@ -529,9 +529,9 @@ def main(arguments=sys.argv[1:]):
|
|||
help='stateOrProvinceName for certicate')
|
||||
parser.add_argument('--locality_name', default='Paris',
|
||||
help='localityName for certicate')
|
||||
parser.add_argument('--organization_name', default='khanat',
|
||||
parser.add_argument('--organization_name', default='OpenNeL',
|
||||
help='organizationName for certicate')
|
||||
parser.add_argument('--common_name', default='khanat',
|
||||
parser.add_argument('--common_name', default='OpenNeL',
|
||||
help='commonName for certicate')
|
||||
print("--")
|
||||
args = parser.parse_args(arguments)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# script to send command to manager khaganat process
|
||||
# script to send command to manager OpenNeL process
|
||||
#
|
||||
# Copyright (C) 2017 AleaJactaEst
|
||||
#
|
||||
|
@ -41,7 +41,7 @@ This script need configuration file (see below for model)::
|
|||
address = 127.0.0.1
|
||||
|
||||
|
||||
Manipulate manager khaganat
|
||||
Manipulate manager OpenNeL
|
||||
---------------------------
|
||||
|
||||
We can end some command to manager.
|
||||
|
@ -66,15 +66,15 @@ We can end some command to manager.
|
|||
|
||||
Example ::
|
||||
|
||||
pyclient --command="START" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="info" --show-log-console
|
||||
pyclient --command="STATUS" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STDIN" --program="aes" --stdin="help all" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STDOUT" --program="aes" --firstline=0 -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STOP" --program="aes" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="LIST" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="SHUTDOWN" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STARTALL" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STATUSALL" -c /home/gameserver/cfg/khaganat.cfg --log="debug" --show-log-console
|
||||
pyclient --command="START" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="info" --show-log-console
|
||||
pyclient --command="STATUS" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STDIN" --program="aes" --stdin="help all" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STDOUT" --program="aes" --firstline=0 -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STOP" --program="aes" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="LIST" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="SHUTDOWN" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STARTALL" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
pyclient --command="STATUSALL" -c /home/gameserver/cfg/opennel_manager.cfg --log="debug" --show-log-console
|
||||
|
||||
|
||||
You can use curl (to replace this script).
|
||||
|
@ -366,6 +366,14 @@ def root(command,
|
|||
client.send_json({'name': program}, 'POST', "/" + command)
|
||||
elif command == 'STATUS':
|
||||
client.send_json({'name': program}, 'GET', "/" + command)
|
||||
elif command == 'CONFIG':
|
||||
client.send_json({'name': program}, 'GET', "/" + command)
|
||||
elif command == 'INFO':
|
||||
client.send_json({'name': program}, 'GET', "/" + command)
|
||||
elif command == 'PLAYER':
|
||||
client.send_json({'name': program}, 'GET', "/" + command)
|
||||
elif command == 'ADMINCOMMAND':
|
||||
client.send_json({'name': program}, 'GET', "/" + command)
|
||||
elif command == 'STDIN':
|
||||
client.send_json({'name': program, 'action': stdin}, 'POST', "/" + command)
|
||||
elif command == 'STDOUT':
|
||||
|
@ -385,7 +393,7 @@ def main(args=sys.argv[1:]):
|
|||
|
||||
:param list args: all arguments ('--help, '--version', ...)
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description='Manipulate khaganat process')
|
||||
parser = argparse.ArgumentParser(description='Manipulate OpenNeL process')
|
||||
parser.add_argument('--version', action='version', version='%(prog)s ' + __VERSION__)
|
||||
parser.add_argument('--show-log-console', action='store_true',
|
||||
help='show message in console', default=False)
|
||||
|
@ -393,8 +401,8 @@ def main(args=sys.argv[1:]):
|
|||
default=None, help='log file')
|
||||
parser.add_argument('--log',
|
||||
default='INFO', help='log level [DEBUG, INFO, WARNING, ERROR')
|
||||
parser.add_argument('--command', help='command send to khganat', default='/STATUS')
|
||||
parser.add_argument('--program', help='program khaganat id', default='aes')
|
||||
parser.add_argument('--command', help='command send to OpenNeL', default='/STATUS')
|
||||
parser.add_argument('--program', help='program OpenNeL id', default='aes')
|
||||
parser.add_argument('--stdin', help='action send to stdin', default='')
|
||||
parser.add_argument('--firstline', type=int,
|
||||
help='define fistline read for log command', default=0)
|
||||
|
@ -405,7 +413,7 @@ def main(args=sys.argv[1:]):
|
|||
'(this option keep current color state)',
|
||||
default=False)
|
||||
parser.add_argument('-c', '--conf', type=argparse.FileType('r'),
|
||||
default='khaganat.cfg', help='configuration file')
|
||||
default='opennel_manager.cfg', help='configuration file')
|
||||
parser.add_argument('-b', '--password-comand-line', action='store_true',
|
||||
help='Use the password from the command line rather than prompting for it.',
|
||||
default=False)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# script to start/stop/status/send command/read log for khaganat process
|
||||
# script to start/stop/status/send command/read log for OpenNeL process
|
||||
#
|
||||
# Copyright (C) 2017 AleaJactaEst
|
||||
#
|
||||
|
@ -88,7 +88,7 @@ This script need configuration file (see below for model)::
|
|||
Manager
|
||||
-------
|
||||
|
||||
Manage all process khaganat
|
||||
Manage all process OpenNeL
|
||||
Launch this prorgam in background and use clientManager to manipulate process
|
||||
|
||||
Design
|
||||
|
@ -101,8 +101,8 @@ Design
|
|||
"Manager" -> "ManageCommand (command 2)";
|
||||
"ManageCommand (command 2)" -> "read_output (thread2)";
|
||||
"Manager" -> "ServerHttp";
|
||||
"ServerHttp" -> "khaganatHTTPServer";
|
||||
"khaganatHTTPServer" -> "ManageHttpRequest";
|
||||
"ServerHttp" -> "OpenNeLHTTPServer";
|
||||
"OpenNeLHTTPServer" -> "ManageHttpRequest";
|
||||
"ManageHttpRequest" -> "ManageCommand (command 1)" [style=dashed];
|
||||
"ManageHttpRequest" -> "ManageCommand (command 2)" [style=dashed];
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ http(s) command :
|
|||
|
||||
Example ::
|
||||
|
||||
nohup pymanager --log info --filelog /home/gameserver/log/manager.log -c /home/gameserver/cfg/khaganat.cfg 2>/dev/null 1>/dev/null 0</dev/zero &
|
||||
nohup pymanager --log info --filelog /home/gameserver/log/manager.log -c /home/gameserver/cfg/opennel_manager.cfg 2>/dev/null 1>/dev/null 0</dev/zero &
|
||||
|
||||
"""
|
||||
|
||||
|
@ -510,9 +510,9 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
self.end_headers()
|
||||
|
||||
|
||||
class khaganatHTTPServer(ThreadingMixIn, http.server.HTTPServer):
|
||||
class OpenNeLHTTPServer(ThreadingMixIn, http.server.HTTPServer):
|
||||
"""
|
||||
Class khaganatHTTPServer
|
||||
Class OpenNeLHTTPServer
|
||||
Redefine HTTPServer (adding queue input & queue output, use by ManageHttpRequest)
|
||||
"""
|
||||
def __init__(self,
|
||||
|
@ -554,7 +554,7 @@ class ServerHttp(multiprocessing.Process):
|
|||
|
||||
def run(self):
|
||||
server_address = (self.address, self.port)
|
||||
httpd = khaganatHTTPServer(self.listQueueIn,
|
||||
httpd = OpenNeLHTTPServer(self.listQueueIn,
|
||||
self.listQueueOut,
|
||||
self.listSemaphore,
|
||||
server_address,
|
||||
|
@ -1350,7 +1350,7 @@ class Manager():
|
|||
activate_filter, size_max_filter, add_filter, del_filter,
|
||||
autostart, restart_after_crash, restart_delay, egs_filter):
|
||||
"""
|
||||
Thread to manage khaganat program
|
||||
Thread to manage OpenNeL program
|
||||
"""
|
||||
logging.debug("Initialize '%s'" % name)
|
||||
manageCommand = ManageCommand(name=name,
|
||||
|
@ -1504,10 +1504,10 @@ def main(args=sys.argv[1:]):
|
|||
|
||||
:param list args: all arguments ('--help, '--version', ...)
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description='Manage khaganat process')
|
||||
parser = argparse.ArgumentParser(description='Manage OpenNeL process')
|
||||
parser.add_argument('--version', action='version', version='%(prog)s ' + __VERSION__)
|
||||
parser.add_argument('-c', '--conf', type=argparse.FileType('r'),
|
||||
default='khaganat.cfg', help='configuration file')
|
||||
default='opennel_manager.cfg', help='configuration file')
|
||||
parser.add_argument('--show-log-console', action='store_true',
|
||||
help='show message in console', default=False)
|
||||
parser.add_argument('--filelog', type=argparse.FileType('wt'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Configuration management program khaganat
|
||||
# Configuration management program OpenNeL
|
||||
#
|
||||
# Copyright (C) 2017 AleaJactaEst
|
||||
#
|
||||
|
|
|
@ -39,8 +39,8 @@ class TestCertificate(unittest.TestCase):
|
|||
self.country_name = 'FR'
|
||||
self.state_or_province_name = 'France'
|
||||
self.locality_name = 'Paris'
|
||||
self.organization_name = 'khanat'
|
||||
self.common_name = 'khanat'
|
||||
self.organization_name = 'OpenNeL'
|
||||
self.common_name = 'OpenNeL'
|
||||
|
||||
def testInitialize(self):
|
||||
logfile = tempfile.NamedTemporaryFile(suffix=".log")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Configuration management program khaganat
|
||||
# Configuration management program OpenNeL
|
||||
#
|
||||
# Copyright (C) 2017 AleaJactaEst
|
||||
#
|
||||
|
|
|
@ -75,8 +75,8 @@ class TestManager(unittest.TestCase):
|
|||
self.country_name = 'FR'
|
||||
self.state_or_province_name = 'France'
|
||||
self.locality_name = 'Paris'
|
||||
self.organization_name = 'khanat'
|
||||
self.common_name = 'khanat'
|
||||
self.organization_name = 'OpenNeL'
|
||||
self.common_name = 'OpenNeL'
|
||||
self.path = os.path.dirname(os.path.abspath(__file__))
|
||||
self.program = os.path.join(self.path, 'simulate_program.py')
|
||||
self.badprogram = os.path.join(self.path, 'test.cfg')
|
||||
|
@ -674,7 +674,7 @@ class TestManager(unittest.TestCase):
|
|||
|
||||
def _runCommand(self, name, command, path, logsize, bufsize, queueIn, queueOut, semaphore):
|
||||
"""
|
||||
Thread to manage khaganat program
|
||||
Thread to manage OpenNeL program
|
||||
"""
|
||||
signal.alarm(10)
|
||||
manageCommand = Manager.ManageCommand(name=name,
|
||||
|
|
Loading…
Reference in a new issue