Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when using command pipenv run alembic upgrade head #58

Open
TheRealPorfavor opened this issue Feb 1, 2022 · 10 comments
Open

error when using command pipenv run alembic upgrade head #58

TheRealPorfavor opened this issue Feb 1, 2022 · 10 comments

Comments

@TheRealPorfavor
Copy link

Hello,

When I run the command pipenv run alembic upgrade head I get the following error:

Traceback (most recent call last):
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/bin/alembic", line 5, in
from alembic.config import main
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/init.py", line 3, in
from . import context
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/context.py", line 1, in
from .runtime.environment import EnvironmentContext
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/runtime/environment.py", line 12, in
from .migration import MigrationContext
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/runtime/migration.py", line 27, in
from .. import ddl
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/ddl/init.py", line 1, in
from . import mssql
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/ddl/mssql.py", line 14, in
from .base import AddColumn
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/ddl/base.py", line 14, in
from ..util.sqla_compat import _columns_for_constraint # noqa
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/util/init.py", line 1, in
from .editor import open_in_editor
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/util/editor.py", line 11, in
from .compat import is_posix
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/alembic/util/compat.py", line 33, in
import importlib_resources # type:ignore[no-redef] # noqa
ModuleNotFoundError: No module named 'importlib_resources'

@jlobue10
Copy link

jlobue10 commented Feb 2, 2022

Try running pipenv install alembic and then re-running pipenv run alembic upgrade head .

@TheRealPorfavor
Copy link
Author

TheRealPorfavor commented Feb 2, 2022

Thanks for the reply.
By using the pipenv install alembic the error was gone after running pipenv run alembic upgrade head again but once I got to pipenv run python -m monitor I got this :

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/jorgen/chia-monitor/monitor/main.py", line 138, in
exporter = ChiaExporter(exporter_port)
File "/home/jorgen/chia-monitor/monitor/exporter.py", line 62, in init
start_http_server(port)
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/prometheus_client/exposition.py", line 148, in start_wsgi_server
httpd = make_server(addr, port, app, ThreadingWSGIServer, handler_class=_SilentHandler)
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.8/socketserver.py", line 452, in init
self.server_bind()
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

@jlobue10
Copy link

jlobue10 commented Feb 2, 2022

Make sure that you have Prometheus installed and working correctly. I have it running as a systemctl service and I'm able to confirm that Prometheus is active and running by issuing sudo systemctl status prometheus at the command line. Once you have confirmed that Prometheus is working properly on your system, make sure that you perform the Basic Prometheus Configuration step from the README. You can confirm this by opening a browser and going to http://localhost:9090/targets and you should see both chia_monitor and prometheus up.

@TheRealPorfavor
Copy link
Author

Thanks again for the reply.

Prometheus is working correctly & running. I have a dashboard with Grafana running that is showing me the stats for my system. All that works fine. I can see Chia_monitor in targets but it shows as DOWN with error : Get "http://localhost:8000/metrics": context deadline exceeded

@TheRealPorfavor
Copy link
Author

any other suggestions? I've tried it a few times but can't get it to work

@jlobue10
Copy link

jlobue10 commented Feb 5, 2022

Make sure that in your /etc/prometheus/prometheus.yml config file under the scrape_configs section that the portion that you added during setup looks something like this.

  - job_name: chia_monitor
    static_configs:
      - targets: ['localhost:8000']

Assuming that you do have the Chia daemons running (which are necessary for this monitoring program to work) from either the Chia GUI or command line farming, you can try sudo netstat -plnt | grep :8000 to see if another program is competing for and clashing on port 8000. In a working setup, you should see a process id/python listening on tcp port 8000. If there is a port clash you should see what else is trying to use port 8000 from running this command and perhaps try a different port.

@TheRealPorfavor
Copy link
Author

TheRealPorfavor commented Feb 5, 2022

I'd like to point out again that I really appreciate all your help!

I've doubled checked and my prometheus.yml has indeed that config under scrape_configs.
I also have node_exporter which is right above it in the yml file and that shows up fine. I re-add the line just to make sure
So that seems to be ok. As I said before, when I go look at the prometheus page (localhost:9090) I can see chia-monitor showing up but it stays DOWN. prometheus & node_exporter also show up as UP.

Chia daemons are running. I have chia CLI farming running. (Chia is started by running chia start all, I assume that started all needed daemons?)

I've tried your command and got the following :
tcp 101 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3841/chia_timelord

So that also seems fine? after a fresh install I still get the following error when I try to run pipenv run python -m monitor :

~/chia-monitor$ pipenv run python -m monitor
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/jorgen/chia-monitor/monitor/main.py", line 138, in
exporter = ChiaExporter(exporter_port)
File "/home/jorgen/chia-monitor/monitor/exporter.py", line 62, in init
start_http_server(port)
File "/home/jorgen/.local/share/virtualenvs/chia-monitor-ou3YiYOO/lib/python3.8/site-packages/prometheus_client/exposition.py", line 148, in start_wsgi_server
httpd = make_server(addr, port, app, ThreadingWSGIServer, handler_class=_SilentHandler)
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.8/socketserver.py", line 452, in init
self.server_bind()
File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

@jlobue10
Copy link

jlobue10 commented Feb 5, 2022

Okay, so I think I fully understand your problem now. The issue is with a port conflict on tcp port 8000. The chia_timelord has a clash with the chia-monitor app on port 8000. It's not necessary to run a Chia timelord though. My guess is that the timelord started when you ran the command chia start all. The command for your main farmer (without starting a timelord) is chia start farmer ("Service farmer will start the farmer, harvester, a full node, and the wallet." source: Chia GitHub Readme files). Run chia stop -d all followed by chia start farmer and then check again to see if you can get the chia-monitor to work. You may need to refresh or restart Prometheus as well. I personally use the Chia GUI on my main farmer since that machine is not starving for resources and I actually like the info that the GUI provides from a quick glance.

@TheRealPorfavor
Copy link
Author

TheRealPorfavor commented Feb 5, 2022

I just got it to work, 2 mins before I saw your reply! So the timelord could be the issue then. I shall investigate further on that. I got to a post on stack overflow after looking for the error [Python [Errno 98] Address already in use] where someone suggest to kill the command on that port to test and and I got it working after that. At first I thought it might have been the chia monitor being stuck somewhere after the first install didn't work but now that I see that the chia timelord could be the issue that would make sense. I just shut everything down (needed to do some cleaning on the computer done) so I will restart the computer soon, use command chia start farmer instead of chia start all and see if the monitor comes up again.

I'll update when I got to that but so far it looks good !
Thanks again! Im pretty new with linux/ubuntu and definitely not used to CLI only so really appreciate all the help you've given!

@TheRealPorfavor
Copy link
Author

Update:

Works like a charm! used the start monitor command after chia started and worked right away.
Thanks again for all the help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants