donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python w/ Flask
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.48k stars 217 forks source link

Don't work on Ubuntu #284

Closed warpwanderer closed 2 weeks ago

warpwanderer commented 3 months ago

Describe The Problem When going to http://:10086 the message is displayed: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Expected Error / Traceback

(myenv) root:~/wgdashboard/src$ sudo ./wgd.sh start
------------------------------------------------------------
| Starting WGDashboard with Gunicorn in the background.    |
Failed to read config file: /home/medraut/wgdashboard/src/gunicorn.conf.py
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename
    spec.loader.exec_module(mod)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/medraut/wgdashboard/src/gunicorn.conf.py", line 2, in <module>
    import dashboard
  File "/home/medraut/wgdashboard/src/dashboard.py", line 23, in <module>
    import ifcfg
ModuleNotFoundError: No module named 'ifcfg'
| Log files is under log/                                  |
------------------------------------------------------------
(myenv) root:~/wgdashboard/src$ ./wgd.sh start
------------------------------------------------------------
| Starting WGDashboard with Gunicorn in the background.    |
| Log files is under log/                                  |
------------------------------------------------------------

To Reproduce http://:10086 in the client browser

OS Information:

Houdoe commented 3 months ago

same here

donaldzou commented 3 months ago

Hi, could you run python3 -m pip install -r requirements.txt in your virtual environment and see if that helps?

donaldzou commented 3 months ago

Hi @Houdoe, are you using an virtual environment? If not, I suggest you to create one since the newer version of Python does not allow user to install global dependencies by default. You can follow this if you're using Debian/Ubuntu system:

$ sudo apt-get install python3.12-venv        << Replace the python version you have on your system
$ cd wgdashboard/src
$ python3 -m venv ./venv
$ source ./venv/bin/activate
(venv) $ python3 -m pip install -r requirements.txt
(venv) $ ./wgd.sh start

Let me know if this helps :)

warpwanderer commented 3 months ago

Hi, could you run python3 -m pip install -r requirements.txt in your virtual environment and see if that helps?

Hello, yes, I used a virtual environment, everything was installed, but when I go to the IP it gives the error Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. if you do not use a virtual environment, the packages are not installed and an error appears on the server related to import ifcfg.

donaldzou commented 3 months ago

Hi, are you still encountering the issue even with venv? Would you able to paste the error when you run ./wgd.sh debug please?

warpwanderer commented 3 months ago

Hi, are you still encountering the issue even with venv? Would you able to paste the error when you run ./wgd.sh debug please?

when venv the error appears in the browser

donaldzou commented 3 months ago

Hi, are you still encountering the issue even with venv? Would you able to paste the error when you run ./wgd.sh debug please?

when venv the error appears in the browser

I see, what if you run ./wgd.sh debug and does it show any error in the console when you access the dashboard?

warpwanderer commented 3 months ago

./wgd.sh debug

It turns out the port is occupied by another program. Can I edit the launch port in the conf file?

(venv) root@:~/wgdashboard/src$ ./wgd.sh debug
------------------------------------------------------------
| Starting WGDashboard in the foreground.                  |
 * Serving Flask app 'WGDashboard'
 * Debug mode: off
Address already in use
Port 10086 is in use by another program. Either identify and stop that program, or start the server with a different port.
warpwanderer commented 3 months ago

Hi, are you still encountering the issue even with venv? Would you able to paste the error when you run ./wgd.sh debug please?

when venv the error appears in the browser

I see, what if you run ./wgd.sh debug and does it show any error in the console when you access the dashboard?

I killed the process on the port, restarted it, again the same error in the browser, but the debug shows:

(venv) medraut@:~/wgdashboard/src$ ./wgd.sh debug
------------------------------------------------------------
| Starting WGDashboard in the foreground.                  |
 * Serving Flask app 'WGDashboard'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:10086
 * Running on http://*.*.*.* :10086
Press CTRL+C to quit
[2024-07-04 20:27:21,704] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 878, in full_dispatch_request
    rv = self.preprocess_request()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1253, in preprocess_request
    rv = self.ensure_sync(before_func)()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 639, in auth_req
    g.db = connect_db()
           ^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 66, in connect_db
    return sqlite3.connect(os.path.join(configuration_path, 'db', 'wgdashboard.db'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file
*.*.*.*  - - [04/Jul/2024 20:27:21] "GET / HTTP/1.1" 500 -
[2024-07-04 20:27:21,975] ERROR in app: Exception on /favicon.ico [GET]
Traceback (most recent call last):
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 878, in full_dispatch_request
    rv = self.preprocess_request()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1253, in preprocess_request
    rv = self.ensure_sync(before_func)()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 639, in auth_req
    g.db = connect_db()
           ^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 66, in connect_db
    return sqlite3.connect(os.path.join(configuration_path, 'db', 'wgdashboard.db'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file
*.*.*.*  - - [04/Jul/2024 20:27:21] "GET /favicon.ico HTTP/1.1" 500 -
[2024-07-04 20:27:22,803] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 878, in full_dispatch_request
    rv = self.preprocess_request()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1253, in preprocess_request
    rv = self.ensure_sync(before_func)()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 639, in auth_req
    g.db = connect_db()
           ^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 66, in connect_db
    return sqlite3.connect(os.path.join(configuration_path, 'db', 'wgdashboard.db'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file
*.*.*.* - - [04/Jul/2024 20:27:22] "GET / HTTP/1.1" 500 -
[2024-07-04 20:27:23,014] ERROR in app: Exception on /favicon.ico [GET]
Traceback (most recent call last):
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 878, in full_dispatch_request
    rv = self.preprocess_request()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/venv/lib/python3.12/site-packages/flask/app.py", line 1253, in preprocess_request
    rv = self.ensure_sync(before_func)()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 639, in auth_req
    g.db = connect_db()
           ^^^^^^^^^^^^
  File "/home/medraut/wgdashboard/src/dashboard.py", line 66, in connect_db
    return sqlite3.connect(os.path.join(configuration_path, 'db', 'wgdashboard.db'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file
95.25.214.72 - - [04/Jul/2024 20:27:23] "GET /favicon.ico HTTP/1.1" 500 -
donaldzou commented 3 months ago

Seems like the dashboard can't find the database... I'm thinking will it caused by permission? Could you please try using sudo and run debug and see if that helps?

warpwanderer commented 3 months ago

Seems like the dashboard can't find the database... I'm thinking will it caused by permission? Could you please try using sudo and run debug and see if that helps?

does not start if used sudo error ModuleNotFoundError: No module named 'ifcfg', without sudo start ok

medraut@:~/wgdashboard/src$ sudo ./wgd.sh start
 [sudo] password for medraut:
 ------------------------------------------------------------
 | Starting WGDashboard with Gunicorn in the background.    |
 Failed to read config file: /home/medraut/wgdashboard/src/gunicorn.conf.py
 Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename
     spec.loader.exec_module(mod)
   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
   File "/home/medraut/wgdashboard/src/gunicorn.conf.py", line 2, in <module>
     import dashboard
   File "/home/medraut/wgdashboard/src/dashboard.py", line 23, in <module>
     import ifcfg
 ModuleNotFoundError: No module named 'ifcfg'
 | Log files is under log/                                  |
 ------------------------------------------------------------
donaldzou commented 3 months ago

Hi,

Sorry for the confusion. I meant using your venv, then sudo.

Something like:

$ source $ sudo ./wgd.sh start

:)

Get Outlook for iOShttps://aka.ms/o0ukef


From: Medraut @.> Sent: Saturday, July 6, 2024 3:24:11 AM To: donaldzou/WGDashboard @.> Cc: Donald Zou @.>; State change @.> Subject: Re: [donaldzou/WGDashboard] Don't work on Ubuntu (Issue #284)

Seems like the dashboard can't find the database... I'm thinking will it caused by permission? Could you please try using sudo and run debug and see if that helps?

does not start if used sudo error ModuleNotFoundError: No module named 'ifcfg', without sudo start ok

medraut@:~/wgdashboard/src$ sudo ./wgd.sh start [sudo] password for medraut:

| Starting WGDashboard with Gunicorn in the background. | Failed to read config file: /home/medraut/wgdashboard/src/gunicorn.conf.py Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename spec.loader.exec_module(mod) File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/home/medraut/wgdashboard/src/gunicorn.conf.py", line 2, in import dashboard File "/home/medraut/wgdashboard/src/dashboard.py", line 23, in import ifcfg ModuleNotFoundError: No module named 'ifcfg' | Log files is under log/ |

— Reply to this email directly, view it on GitHubhttps://github.com/donaldzou/WGDashboard/issues/284#issuecomment-2211318177, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUL3BUOU3TYZUZ4AXLLZK3XFXAVCNFSM6AAAAABKJ5UHTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRGMYTQMJXG4. You are receiving this because you modified the open/close state.Message ID: @.***>

warpwanderer commented 3 months ago

That's exactly what I did

donaldzou commented 3 months ago

Seems like the dashboard can't find the database... I'm thinking will it caused by permission? Could you please try using sudo and run debug and see if that helps?

does not start if used sudo error ModuleNotFoundError: No module named 'ifcfg', without sudo start ok


medraut@:~/wgdashboard/src$ sudo ./wgd.sh start

 [sudo] password for medraut:

 ------------------------------------------------------------

 | Starting WGDashboard with Gunicorn in the background.    |

 Failed to read config file: /home/medraut/wgdashboard/src/gunicorn.conf.py

 Traceback (most recent call last):

   File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename

     spec.loader.exec_module(mod)

   File "<frozen importlib._bootstrap_external>", line 995, in exec_module

   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed

   File "/home/medraut/wgdashboard/src/gunicorn.conf.py", line 2, in <module>

     import dashboard

   File "/home/medraut/wgdashboard/src/dashboard.py", line 23, in <module>

     import ifcfg

 ModuleNotFoundError: No module named 'ifcfg'

 | Log files is under log/                                  |

 ------------------------------------------------------------

Hmm I don't think you used venv in this one.. it should have a bracket wrapping your venv's name before each command.

warpwanderer commented 3 months ago

Sorry, you are right, the fact is that the first time I tried without venv, but the second time it was venv, I sent you the old debug since it was no different, the situation does not change if you use sudo

сб, 6 июл. 2024 г. в 11:51, Donald Zou @.***>:

Seems like the dashboard can't find the database... I'm thinking will it caused by permission? Could you please try using sudo and run debug and see if that helps?

does not start if used sudo error ModuleNotFoundError: No module named 'ifcfg', without sudo start ok

medraut@:~/wgdashboard/src$ sudo ./wgd.sh start

[sudo] password for medraut:


| Starting WGDashboard with Gunicorn in the background. |

Failed to read config file: /home/medraut/wgdashboard/src/gunicorn.conf.py

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 111, in get_config_from_filename

 spec.loader.exec_module(mod)

File "", line 995, in exec_module

File "", line 488, in _call_with_frames_removed

File "/home/medraut/wgdashboard/src/gunicorn.conf.py", line 2, in

 import dashboard

File "/home/medraut/wgdashboard/src/dashboard.py", line 23, in

 import ifcfg

ModuleNotFoundError: No module named 'ifcfg'

| Log files is under log/ |


Hmm I don't think you used venv in this one.. it should have a bracket wrapping your venv's name before each command.

— Reply to this email directly, view it on GitHub https://github.com/donaldzou/WGDashboard/issues/284#issuecomment-2211710777, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMAAANVFH37U5AIJYJOGETZK6VYJAVCNFSM6AAAAABKJ5UHTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRG4YTANZXG4 . You are receiving this because you modified the open/close state.Message ID: @.***>

DaanSelen commented 1 month ago

Is this issue fixed?

warpwanderer commented 2 weeks ago

Is this issue fixed?

Yes, I checked today, installed everything from the beginning, everything works fine

DaanSelen commented 2 weeks ago

So this issue is solved?

warpwanderer commented 2 weeks ago

So this issue is solved?

Yes, that's right, we can close it, thank you.