ratibor78 / geostat

GeoStat, Python script for parsing Nginx and Apache logs files and getting GEO data from incoming IP's.
MIT License
67 stars 20 forks source link

Neither a valid executable name nor an absolute path: $PWD/venv/bin/python #10

Closed olegsidokhmetov closed 3 years ago

olegsidokhmetov commented 3 years ago
(venv) root@NC-V3:~/geostat# systemctl start geostat.service

Failed to start geostat.service: Unit geostat.service has a bad unit file setting.
See system logs and 'systemctl status geostat.service' for details.

(venv) root@NC-V3:~/geostat# systemctl status geostat.service
● geostat.service - GeoStat
     Loaded: bad-setting (Reason: Unit geostat.service has a bad unit file setting.)
     Active: inactive (dead)

Nov 12 11:18:14 NC-V3 systemd[1]: /lib/systemd/system/geostat.service:8: Neither a valid executable name nor an absolute path: $PWD/venv/bin/python
Nov 12 11:18:14 NC-V3 systemd[1]: geostat.service: Unit configuration has fatal error, unit will not be started.

Settings: nano /lib/systemd/system/geostat.service

[Unit]
Description=GeoStat
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/root/geostat/venv/bin/python geoparser.py
User=root
WorkingDirectory=/root/geostat
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

How I can solve this issue?

olegsidokhmetov commented 3 years ago

Hello!

Today I a little bit changed text ini file to:

[Unit]
Description=GeoStat
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/root/geostat/venv/bin/python geoparser.py
User=root
WorkingDirectory=/root/geostat
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

And have a new error

root@NC-V3:~# systemctl start geostat.service
root@NC-V3:~# systemctl status geostat.service
● geostat.service - GeoStat
     Loaded: loaded (/lib/systemd/system/geostat.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2020-11-13 08:58:38 UTC; 1s ago
    Process: 34771 ExecStart=/root/geostat/venv/bin/python geoparser.py (code=exited, status=1/FAILURE)
   Main PID: 34771 (code=exited, status=1/FAILURE)

and log from syslog


root@NC-V3:~# cat /var/log/syslog | grep geo
Nov 13 09:02:07 NC-V3 systemd[1]: geostat.service: Main process exited, code=exited, status=1/FAILURE
Nov 13 09:02:07 NC-V3 systemd[1]: geostat.service: Failed with result 'exit-code'.
Nov 13 09:02:09 NC-V3 systemd[1]: geostat.service: Scheduled restart job, restart counter is at 106.
Nov 13 09:02:09 NC-V3 python[34870]:   File "geoparser.py", line 14, in <module>
Nov 13 09:02:09 NC-V3 python[34870]:   File "/root/geostat/venv/lib/python3.8/site-packages/Geohash/__init__.py", line 21, in <module>
Nov 13 09:02:09 NC-V3 python[34870]:     from geohash import decode_exactly, decode, encode
Nov 13 09:02:09 NC-V3 python[34870]: ModuleNotFoundError: No module named 'geohash'
Nov 13 09:02:09 NC-V3 systemd[1]: geostat.service: Main process exited, code=exited, status=1/FAILURE
Nov 13 09:02:09 NC-V3 systemd[1]: geostat.service: Failed with result 'exit-code'.
olegsidokhmetov commented 3 years ago

SO!

I found solution for this problem! https://github.com/vinsci/geohash/issues/4#issuecomment-292118721 I had the same issue - if you rename the package name to be geohash rather than Geohash and then change __init__.py to import from .geohash (with a dot in front of the module name) rather than from geohash, the package should work for Python 3.5.2.

But I changed file nano /root/geostat/venv/lib/python3.8/site-packages/Geohash/__init__.py to from Geohash import decode_exactly, decode, encode , was geohash

I think will be better if you change file configuration

root@NC-V3:~/geostat# systemctl status geostat.service
● geostat.service - GeoStat
     Loaded: loaded (/lib/systemd/system/geostat.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2020-11-13 10:02:35 UTC; 45ms ago
   Main PID: 36690 (python)
      Tasks: 1 (limit: 4620)
     Memory: 5.9M
     CGroup: /system.slice/geostat.service
             └─36690 /root/geostat/venv/bin/python geoparser.py
ratibor78 commented 3 years ago

Yep, the Geohash module was changed and you find the right way to fix it. I'm working on a new updated version of this script, that will fix the all existing issues and also will have logging and some extra features, please hold on, it'll be available soon.