SystemRage / py-kms

KMS Server Emulator written in Python
The Unlicense
2.07k stars 634 forks source link

error when running under systemd #30

Closed eth-man closed 5 years ago

eth-man commented 5 years ago

When trying to run under Systemd i'm getting the following error

May 21 23:07:24 rpi3 systemd[1]: Started PY-KMS Service. May 21 23:07:26 rpi3 python3[8791]: Traceback (most recent call last): May 21 23:07:26 rpi3 python3[8791]: File "/opt/py-kms/py-kms/pykms_Server.py", line 266, in <module> May 21 23:07:26 rpi3 python3[8791]: srv_main_with_gui() May 21 23:07:26 rpi3 python3[8791]: File "/opt/py-kms/py-kms/pykms_Server.py", line 197, in srv_main_with_gui May 21 23:07:26 rpi3 python3[8791]: root = pykms_GuiBase.KmsGui() May 21 23:07:26 rpi3 python3[8791]: File "/opt/py-kms/py-kms/pykms_GuiBase.py", line 77, in __init__ May 21 23:07:26 rpi3 python3[8791]: tk.Tk.__init__(self, *args, **kwargs) May 21 23:07:26 rpi3 python3[8791]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__ May 21 23:07:26 rpi3 python3[8791]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) May 21 23:07:26 rpi3 python3[8791]: _tkinter.TclError: no display name and no $DISPLAY environment variable May 21 23:07:26 rpi3 systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE

bruor commented 5 years ago

I think this is similar to an issue that I'm seeing when running pykms_Server.py using the daemon command on FreeBSD.

When using daemon with -f (for send output to /dev/null) or -r to monitor and restart the service if it dies, the code below seems to thing the process should run in GUI mode which causes it to crash. I fixed this by changing both conditions to call srv_main_without_gui(), also had to override line 190 of pykms_Format.py. perhaps an argument can be added to specify nogui/daemon. Will try to take a stab at this if I can find some time this week.

if name == "main": if sys.stdout.isatty(): srv_main_without_gui() else: srv_main_with_gui()

SystemRage commented 5 years ago

https://github.com/SystemRage/py-kms/issues/34#issuecomment-498438644