Compare commits
No commits in common. "master" and "monitor" have entirely different histories.
4 changed files with 27 additions and 41 deletions
|
@ -1,16 +0,0 @@
|
||||||
FROM alpine:latest
|
|
||||||
WORKDIR /opt/
|
|
||||||
|
|
||||||
ENV GIT_URL=https://git.adrianux.net
|
|
||||||
ENV WEBSITE_URL=https://adrianux.net
|
|
||||||
ENV DEBUG_MODE=False
|
|
||||||
|
|
||||||
RUN apk add --no-cache git python3
|
|
||||||
RUN git clone https://git.adrianux.net/ahoemann/Adrianux.net.git /opt
|
|
||||||
RUN python3 -m venv /opt/.venv
|
|
||||||
RUN /opt/.venv/bin/pip install --no-cache-dir -r requirements.txt
|
|
||||||
RUN apk del git
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
CMD [ "/opt/.venv/bin/waitress-serve", "--listen=0.0.0.0:8080", "app:app" ]
|
|
23
README.md
23
README.md
|
@ -18,15 +18,20 @@ python3 -m venv .venv
|
||||||
pip install requirements.txt
|
pip install requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building the container
|
```systemd
|
||||||
|
# /etc/systemd/system/adrianux.service
|
||||||
|
[Unit]
|
||||||
|
Description=WSGI app
|
||||||
|
After=network.target
|
||||||
|
|
||||||
```
|
[Service]
|
||||||
# <runtime> build -t adrianux:<tag> .
|
Type=simple
|
||||||
|
User=adrianux
|
||||||
|
WorkingDirectory=/opt/Adrianux.net
|
||||||
|
ExecStart=/opt/Adrianux.net/.venv/bin/waitress-serve --listen=127.0.0.1:8080 app:app
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Running the container
|
|
||||||
|
|
||||||
```
|
|
||||||
# <runtime> run adrianux:<tag>
|
|
||||||
```
|
|
||||||
|
|
25
app.py
25
app.py
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from flask import Flask, render_template, redirect, url_for
|
from flask import Flask, render_template, redirect, url_for
|
||||||
import requests
|
import requests
|
||||||
import os
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@ -19,24 +18,22 @@ def homepage():
|
||||||
|
|
||||||
@app.route("/monitoring")
|
@app.route("/monitoring")
|
||||||
def monitoring():
|
def monitoring():
|
||||||
git_url = os.environ['GIT_URL']
|
git_status = get_status("https://git.adrianux.net")
|
||||||
website_url = os.environ['WEBSITE_URL']
|
website_status = get_status("https://adrianux.net")
|
||||||
return render_template("monitoring.html", git_status = get_status(git_url), website_status = get_status(website_url) )
|
return render_template("monitoring.html", git_status = git_status, website_status = website_status )
|
||||||
|
|
||||||
def get_status_code(link):
|
def get_status_code(link):
|
||||||
requested_site = requests.get(link)
|
requested_site = requests.get(link)
|
||||||
return requested_site.status_code
|
return requested_site.status_code
|
||||||
|
|
||||||
def get_status(link):
|
def get_status(link):
|
||||||
try:
|
match get_status_code(link):
|
||||||
match get_status_code(link):
|
case 200:
|
||||||
case 200:
|
return "ONLINE"
|
||||||
return "ONLINE"
|
case 500:
|
||||||
case _:
|
return "ERROR"
|
||||||
return "ERROR"
|
case _:
|
||||||
except:
|
return "OFFLINE"
|
||||||
return "OFFLINE"
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
mode = os.environ['DEBUG_MODE']
|
app.run(debug=False)
|
||||||
app.run(debug=mode)
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer class="container">
|
<footer class="container">
|
||||||
<p><a href="mailto:ahoemann@proton.me">ahoemann@proton.me</a>
|
<p><a href="mailto:ahoemann@proton.me">ahoemann@proton.me</a></p>
|
||||||
</p>Authored by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
© Copyright 2024 by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue