2022-03-22 21:18:04 +08:00
|
|
|
# -------------------------------
|
2021-09-08 23:38:34 +08:00
|
|
|
# Difficult Rocket
|
2021-12-26 23:06:03 +08:00
|
|
|
# Copyright © 2021-2022 by shenjackyuanjie
|
2021-09-08 23:38:34 +08:00
|
|
|
# All rights reserved
|
|
|
|
# -------------------------------
|
|
|
|
|
2021-02-22 21:32:13 +08:00
|
|
|
"""
|
2021-01-21 15:05:29 +08:00
|
|
|
writen by shenjackyuanjie
|
2021-09-08 23:38:34 +08:00
|
|
|
mail: 3695888@qq.com
|
|
|
|
github: @shenjackyuanjie
|
|
|
|
gitee: @shenjackyuanjie
|
2021-02-22 21:32:13 +08:00
|
|
|
"""
|
2021-09-08 23:38:34 +08:00
|
|
|
|
2021-04-03 12:15:24 +08:00
|
|
|
import os
|
2021-08-24 22:31:52 +08:00
|
|
|
import sys
|
2022-03-22 21:18:04 +08:00
|
|
|
import logging
|
2021-08-24 22:31:52 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__': # been start will not run this
|
|
|
|
sys.path.append('/bin/libs')
|
|
|
|
sys.path.append('/bin')
|
|
|
|
|
2022-03-22 21:18:04 +08:00
|
|
|
from utils import tools
|
2022-02-22 23:22:11 +08:00
|
|
|
from Difficult_Rocket.api.delivery import Delivery
|
2022-03-22 21:18:04 +08:00
|
|
|
from utils.new_thread import new_thread
|
2021-01-21 15:05:29 +08:00
|
|
|
|
2021-09-05 00:50:05 +08:00
|
|
|
|
2021-08-24 22:31:52 +08:00
|
|
|
# TODO 改变服务端启动逻辑 0.6.0会写完的(
|
2021-02-22 21:32:13 +08:00
|
|
|
|
2021-01-21 15:05:29 +08:00
|
|
|
|
2021-08-24 22:31:52 +08:00
|
|
|
class Server:
|
2021-09-22 06:21:48 +08:00
|
|
|
def __init__(self, net_mode='local', Dev: Delivery = Delivery):
|
2021-01-21 15:05:29 +08:00
|
|
|
# father class __init__()
|
2021-08-13 12:25:29 +08:00
|
|
|
# mp.Process.__init__(self)
|
2021-01-25 12:22:55 +08:00
|
|
|
# logging
|
2021-08-13 12:25:29 +08:00
|
|
|
self.logger = logging.getLogger('server')
|
2021-01-21 15:05:29 +08:00
|
|
|
# value
|
2021-01-23 19:55:35 +08:00
|
|
|
self.process_id = 'Server'
|
|
|
|
self.process_name = 'server process'
|
2021-08-13 12:25:29 +08:00
|
|
|
# config
|
2021-09-28 22:47:19 +08:00
|
|
|
self.config = tools.load_file('configs/main.config')
|
2021-08-24 22:31:52 +08:00
|
|
|
self.dev = Dev
|
|
|
|
self.net_mode = net_mode
|
2021-02-22 21:32:13 +08:00
|
|
|
# lang
|
2021-09-28 22:47:19 +08:00
|
|
|
self.lang = tools.load_file('configs/lang/%s.json5' % self.config['runtime']['language'], 'server')
|
2021-02-22 21:32:13 +08:00
|
|
|
self.logger.info('%s' % self.lang['setup.done'])
|
2021-01-21 15:05:29 +08:00
|
|
|
|
2021-08-24 22:31:52 +08:00
|
|
|
@new_thread('Server')
|
2021-01-21 15:05:29 +08:00
|
|
|
def run(self):
|
2021-08-13 12:25:29 +08:00
|
|
|
self.logger.info(self.lang['os.pid_is'].format(os.getpid(), os.getppid()))
|