swar / Swar-Chia-Plot-Manager

This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.
GNU General Public License v3.0
1.26k stars 389 forks source link

Starting view och json after manager is running cause metrics server to be started a second time #657

Open jhoglin opened 3 years ago

jhoglin commented 3 years ago

I'm too new with Python but this global handling must be broken somhow. https://github.com/swar/Swar-Chia-Plot-Manager/blob/a4621ff21f7ef7659aa02e82036aa038ae832712/plotmanager/library/utilities/instrumentation.py#L4

Starting manager first

python3 manager.py start
Plot Manager has started...

then start the view, the view process has no knowledge about the global PROCESSED from start of manager, so it will try to start a second server using the same port and the result is:

python3 manager.py view
              ->   processed 1 False.    # MY OWN PRINT TO DEBUG THIS
Traceback (most recent call last):
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/manager.py", line 37, in <module>
    view()
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/plotmanager/library/utilities/commands.py", line 162, in view
    jobs, running_work = get_running_plots(jobs=jobs, running_work=running_work,
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/plotmanager/library/utilities/processes.py", line 254, in get_running_plots
    set_plots_running(total_running_plots=assumed_job.total_running, job_name=assumed_job.name,
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/plotmanager/library/utilities/instrumentation.py", line 26, in set_plots_running
    _get_metrics(instrumentation_settings=instrumentation_settings)
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/plotmanager/library/utilities/instrumentation.py", line 20, in _get_metrics
    start_http_server(port)
  File "/home/jhoglin/chia/Swar-Chia-Plot-Manager/venv/lib/python3.9/site-packages/prometheus_client/exposition.py", line 149, in start_wsgi_server
    httpd = make_server(addr, port, app, ThreadingWSGIServer, handler_class=_SilentHandler)
  File "/usr/lib/python3.9/wsgiref/simple_server.py", line 154, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/lib/python3.9/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.9/wsgiref/simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/lib/python3.9/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.9/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
iwex commented 3 years ago

I have the same issue

iwex commented 3 years ago

Tried to fix :) https://github.com/swar/Swar-Chia-Plot-Manager/pull/660

iwex commented 3 years ago

Anyway, it's not working correctly. When I restart the manager it fails to update values, so for now it responds only with 1 job running..