Open MehrabD123 opened 2 years ago
Hi, could you post your wg-dashboard.service
file so I can have a look?
here is the file
Yeah my bad, i did not fix this issue... Here is a working copy of it that i have in v2.3
:
[Unit]
After=netword.service
[Service]
WorkingDirectory=<your dashboard directory full path here>
ExecStart=/usr/bin/python3 <your dashboard directory full path here>dashboard.py
Restart=always
[Install]
WantedBy=default.target
Make sure you remove everything in wg-dashboard.service
, paste the stuff above, and you follow this instruction:
In the src
folder, it contained a file called wg-dashboard.service
, we can use this file to let our system to autostart the dashboard after reboot. The following guide has tested on Ubuntu, most Debian based OS might be the same, but some might not. Please don't hesitate to provide your system if you have tested the autostart on another system.
Changing the directory to the dashboard's directory
cd wireguard-dashboard/src
Get the full path of the dashboard's directory
pwd
#Output: /root/wireguard-dashboard/src
For this example, the output is /root/wireguard-dashboard/src
, your path might be different since it depends on where you downloaded the dashboard in the first place. Copy the the output to somewhere, we will need this in the next step.
Edit the service file, the service file is located in wireguard-dashboard/src
, you can use other editor you like, here will be using nano
nano wg-dashboard.service
You will see something like this:
[Unit]
After=netword.service
[Service]
WorkingDirectory=<your dashboard directory full path here>
ExecStart=/usr/bin/python3 <your dashboard directory full path here>/dashboard.py
Restart=always
[Install]
WantedBy=default.target
Now, we need to replace both <your dashboard directory full path here>
to the one you just copied from step 2. After doing this, the file will become something like this, your file might be different:
[Unit]
After=netword.service
[Service]
WorkingDirectory=/root/wireguard-dashboard/src
ExecStart=/usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
Restart=always
[Install]
WantedBy=default.target
Be aware that after the value of WorkingDirectory
, it does not have a /
(slash). And then save the file after you edited it
Copy the service file to systemd folder
$ cp wg-dashboard.service /etc/systemd/system/wg-dashboard.service
To make sure you copy the file successfully, you can use this command cat /etc/systemd/system/wg-dashboard.service
to see if it will output the file you just edited.
Enable the service
$ sudo chmod 664 /etc/systemd/system/wg-dashboard.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable wg-dashboard.service
$ sudo systemctl start wg-dashboard.service # <-- To start the service
Check if the service run correctly
$ sudo systemctl status wg-dashboard.service
And you should see something like this
● wg-dashboard.service
Loaded: loaded (/etc/systemd/system/wg-dashboard.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-03 22:31:26 UTC; 4s ago
Main PID: 6602 (python3)
Tasks: 1 (limit: 453)
Memory: 26.1M
CGroup: /system.slice/wg-dashboard.service
└─6602 /usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
Aug 03 22:31:26 ubuntu-wg systemd[1]: Started wg-dashboard.service.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Serving Flask app "Wireguard Dashboard" (lazy loading)
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Environment: production
Aug 03 22:31:27 ubuntu-wg python3[6602]: WARNING: This is a development server. Do not use it in a production deployment.
Aug 03 22:31:27 ubuntu-wg python3[6602]: Use a production WSGI server instead.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Debug mode: off
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Running on all addresses.
Aug 03 22:31:27 ubuntu-wg python3[6602]: WARNING: This is a development server. Do not use it in a production deployment.
Aug 03 22:31:27 ubuntu-wg python3[6602]: * Running on http://0.0.0.0:10086/ (Press CTRL+C to quit)
If you see Active:
followed by active (running) since...
then it means it run correctly.
Stop/Start/Restart the service
sudo systemctl stop wg-dashboard.service # <-- To stop the service
sudo systemctl start wg-dashboard.service # <-- To start the service
sudo systemctl restart wg-dashboard.service # <-- To restart the service
And now you can reboot your system, and use the command at step 6 to see if it will auto start after the reboot, or just simply access the dashboard through your browser. If you have any questions or problem, please report it in the issue page.
Let me know how it goes ;)
this worked perfectly! thank you so much for the help i really appreciate it
i may have spoke too soon, this is the error i got on system reboot any ideas as to what the issue is?
it works when i run sudo systemctl start wg-dashboard.service
i am just unsure why it did not start on reboot
it works when i run
sudo systemctl start wg-dashboard.service
i am just unsure why it did not start on reboot
@MehrabD123 You'll also need to do sudo systemctl enable wg-dashboard.service
to have it auto start on reboot.
i had already enabled it when following the instructions, but i still get the same issue i posted above
@MehrabD123 The actual error isn't given in that screen shot try journalctl -xeu wg-dashboard.service
, you should be able to scroll back far enough to see a real error.
It might because you did not reload the file, try systemctl daemon-reload
also could try which python3
on your pi? It should tell you where python installed, it might different from the example I provided above.
@MehrabD123 is this still relevant?
after following the steps to enable on startup start for wg-dashboard, i get this error when doing sudo systemctl start wg-dashboard.service
OS Information: