New argument: --socketfile that create a socket for internal communication
This commit is contained in:
parent
0b14207c88
commit
c0fed51fde
@ -38,8 +38,8 @@ def requires_version(min=None, max=None):
|
|||||||
"but this is nemubot v%s." % (str(max), __version__))
|
"but this is nemubot v%s." % (str(max), __version__))
|
||||||
|
|
||||||
|
|
||||||
def attach(pid):
|
def attach(socketfile):
|
||||||
print("TODO, attach to %d" % pid)
|
print("TODO: Attach to Unix socket at: %s" % socketfile)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ def main():
|
|||||||
parser.add_argument("-P", "--pidfile", default="./nemubot.pid",
|
parser.add_argument("-P", "--pidfile", default="./nemubot.pid",
|
||||||
help="Path to the file where store PID")
|
help="Path to the file where store PID")
|
||||||
|
|
||||||
|
parser.add_argument("-S", "--socketfile", default="./nemubot.sock",
|
||||||
|
help="path where open the socket for internal communication")
|
||||||
|
|
||||||
parser.add_argument("-l", "--logfile", default="./nemubot.log",
|
parser.add_argument("-l", "--logfile", default="./nemubot.log",
|
||||||
help="Path to store logs")
|
help="Path to store logs")
|
||||||
|
|
||||||
@ -66,6 +69,7 @@ def main():
|
|||||||
# Resolve relatives paths
|
# Resolve relatives paths
|
||||||
args.data_path = os.path.abspath(os.path.expanduser(args.data_path))
|
args.data_path = os.path.abspath(os.path.expanduser(args.data_path))
|
||||||
args.pidfile = os.path.abspath(os.path.expanduser(args.pidfile))
|
args.pidfile = os.path.abspath(os.path.expanduser(args.pidfile))
|
||||||
|
args.socketfile = os.path.abspath(os.path.expanduser(args.socketfile))
|
||||||
args.logfile = os.path.abspath(os.path.expanduser(args.logfile))
|
args.logfile = os.path.abspath(os.path.expanduser(args.logfile))
|
||||||
args.files = [ x for x in map(os.path.abspath, args.files)]
|
args.files = [ x for x in map(os.path.abspath, args.files)]
|
||||||
args.modules_path = [ x for x in map(os.path.abspath, args.modules_path)]
|
args.modules_path = [ x for x in map(os.path.abspath, args.modules_path)]
|
||||||
@ -185,6 +189,11 @@ def main():
|
|||||||
# Here we go!
|
# Here we go!
|
||||||
context.start()
|
context.start()
|
||||||
|
|
||||||
|
if args.socketfile:
|
||||||
|
from nemubot.server.socket import SocketListener
|
||||||
|
context.add_server(SocketListener(context.add_server, "master_socket",
|
||||||
|
sock_location=args.socketfile))
|
||||||
|
|
||||||
# context can change when performing an hotswap, always join the latest context
|
# context can change when performing an hotswap, always join the latest context
|
||||||
oldcontext = None
|
oldcontext = None
|
||||||
while oldcontext != context:
|
while oldcontext != context:
|
||||||
|
Loading…
Reference in New Issue
Block a user