mirror of https://github.com/Desuuuu/klipper.git
webhooks: Specify server_address on klippy command-line
Don't default to "/tmp/klippy_uds" for the webhooks unix domain socket filename. Instead, require the filename to be specified on the command-line (via a new "-a" parameter). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
ebc79a1ee8
commit
0aad2437c5
|
@ -247,6 +247,8 @@ def main():
|
||||||
opts.add_option("-I", "--input-tty", dest="inputtty",
|
opts.add_option("-I", "--input-tty", dest="inputtty",
|
||||||
default='/tmp/printer',
|
default='/tmp/printer',
|
||||||
help="input tty name (default is /tmp/printer)")
|
help="input tty name (default is /tmp/printer)")
|
||||||
|
opts.add_option("-a", "--api-server", dest="apiserver",
|
||||||
|
help="api server unix domain socket filename")
|
||||||
opts.add_option("-l", "--logfile", dest="logfile",
|
opts.add_option("-l", "--logfile", dest="logfile",
|
||||||
help="write log to file instead of stderr")
|
help="write log to file instead of stderr")
|
||||||
opts.add_option("-v", action="store_true", dest="verbose",
|
opts.add_option("-v", action="store_true", dest="verbose",
|
||||||
|
@ -259,7 +261,8 @@ def main():
|
||||||
options, args = opts.parse_args()
|
options, args = opts.parse_args()
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
opts.error("Incorrect number of arguments")
|
opts.error("Incorrect number of arguments")
|
||||||
start_args = {'config_file': args[0], 'start_reason': 'startup'}
|
start_args = {'config_file': args[0], 'apiserver': options.apiserver,
|
||||||
|
'start_reason': 'startup'}
|
||||||
|
|
||||||
debuglevel = logging.INFO
|
debuglevel = logging.INFO
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
|
|
|
@ -11,8 +11,6 @@ import errno
|
||||||
import json
|
import json
|
||||||
import homing
|
import homing
|
||||||
|
|
||||||
SERVER_ADDRESS = "/tmp/klippy_uds"
|
|
||||||
|
|
||||||
# Json decodes strings as unicode types in Python 2.x. This doesn't
|
# Json decodes strings as unicode types in Python 2.x. This doesn't
|
||||||
# play well with some parts of Klipper (particuarly displays), so we
|
# play well with some parts of Klipper (particuarly displays), so we
|
||||||
# need to create an object hook. This solution borrowed from:
|
# need to create an object hook. This solution borrowed from:
|
||||||
|
@ -98,15 +96,16 @@ class ServerSocket:
|
||||||
self.reactor = printer.get_reactor()
|
self.reactor = printer.get_reactor()
|
||||||
self.sock = self.fd_handle = None
|
self.sock = self.fd_handle = None
|
||||||
self.clients = {}
|
self.clients = {}
|
||||||
is_fileinput = (printer.get_start_args().get('debuginput')
|
start_args = printer.get_start_args()
|
||||||
is not None)
|
server_address = start_args.get('apiserver')
|
||||||
if is_fileinput:
|
is_fileinput = (start_args.get('debuginput') is not None)
|
||||||
# Do not enable server in batch mode
|
if not server_address or is_fileinput:
|
||||||
|
# Do not enable server
|
||||||
return
|
return
|
||||||
self._remove_socket_file(SERVER_ADDRESS)
|
self._remove_socket_file(server_address)
|
||||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
self.sock.setblocking(0)
|
self.sock.setblocking(0)
|
||||||
self.sock.bind(SERVER_ADDRESS)
|
self.sock.bind(server_address)
|
||||||
self.sock.listen(1)
|
self.sock.listen(1)
|
||||||
self.fd_handle = self.reactor.register_fd(
|
self.fd_handle = self.reactor.register_fd(
|
||||||
self.sock.fileno(), self._handle_accept)
|
self.sock.fileno(), self._handle_accept)
|
||||||
|
|
Loading…
Reference in New Issue