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
|
||||
```
|
||||
|
||||
## Building the container
|
||||
```systemd
|
||||
# /etc/systemd/system/adrianux.service
|
||||
[Unit]
|
||||
Description=WSGI app
|
||||
After=network.target
|
||||
|
||||
```
|
||||
# <runtime> build -t adrianux:<tag> .
|
||||
[Service]
|
||||
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>
|
||||
```
|
||||
|
|
15
app.py
15
app.py
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from flask import Flask, render_template, redirect, url_for
|
||||
import requests
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
@ -19,24 +18,22 @@ def homepage():
|
|||
|
||||
@app.route("/monitoring")
|
||||
def monitoring():
|
||||
git_url = os.environ['GIT_URL']
|
||||
website_url = os.environ['WEBSITE_URL']
|
||||
return render_template("monitoring.html", git_status = get_status(git_url), website_status = get_status(website_url) )
|
||||
git_status = get_status("https://git.adrianux.net")
|
||||
website_status = get_status("https://adrianux.net")
|
||||
return render_template("monitoring.html", git_status = git_status, website_status = website_status )
|
||||
|
||||
def get_status_code(link):
|
||||
requested_site = requests.get(link)
|
||||
return requested_site.status_code
|
||||
|
||||
def get_status(link):
|
||||
try:
|
||||
match get_status_code(link):
|
||||
case 200:
|
||||
return "ONLINE"
|
||||
case _:
|
||||
case 500:
|
||||
return "ERROR"
|
||||
except:
|
||||
case _:
|
||||
return "OFFLINE"
|
||||
|
||||
if __name__ == "__main__":
|
||||
mode = os.environ['DEBUG_MODE']
|
||||
app.run(debug=mode)
|
||||
app.run(debug=False)
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
</main>
|
||||
|
||||
<footer class="container">
|
||||
<p><a href="mailto:ahoemann@proton.me">ahoemann@proton.me</a>
|
||||
</p>Authored by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
||||
<p><a href="mailto:ahoemann@proton.me">ahoemann@proton.me</a></p>
|
||||
© Copyright 2024 by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue