Compare commits
16 commits
Author | SHA1 | Date | |
---|---|---|---|
2b6885055b | |||
95d6497e93 | |||
e034601337 | |||
|
e9b32af7c7 | ||
4581e65109 | |||
|
4f73502d00 | ||
|
a6aae99ed0 | ||
|
fda16a4744 | ||
|
546a5ab34c | ||
|
eb0f406a51 | ||
b75e83c6c1 | |||
b39983777b | |||
c2bb0cc6cc | |||
4d2fe89cd5 | |||
80a0affc4b | |||
4c76eb3f1b |
4 changed files with 41 additions and 27 deletions
16
Containerfile
Normal file
16
Containerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
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,20 +18,15 @@ python3 -m venv .venv
|
||||||
pip install requirements.txt
|
pip install requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
```systemd
|
## Building the container
|
||||||
# /etc/systemd/system/adrianux.service
|
|
||||||
[Unit]
|
|
||||||
Description=WSGI app
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
```
|
||||||
Type=simple
|
# <runtime> build -t adrianux:<tag> .
|
||||||
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,6 +1,7 @@
|
||||||
#!/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__)
|
||||||
|
|
||||||
|
@ -18,22 +19,24 @@ def homepage():
|
||||||
|
|
||||||
@app.route("/monitoring")
|
@app.route("/monitoring")
|
||||||
def monitoring():
|
def monitoring():
|
||||||
git_status = get_status("https://git.adrianux.net")
|
git_url = os.environ['GIT_URL']
|
||||||
website_status = get_status("https://adrianux.net")
|
website_url = os.environ['WEBSITE_URL']
|
||||||
return render_template("monitoring.html", git_status = git_status, website_status = website_status )
|
return render_template("monitoring.html", git_status = get_status(git_url), website_status = get_status(website_url) )
|
||||||
|
|
||||||
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):
|
||||||
match get_status_code(link):
|
try:
|
||||||
case 200:
|
match get_status_code(link):
|
||||||
return "ONLINE"
|
case 200:
|
||||||
case 500:
|
return "ONLINE"
|
||||||
return "ERROR"
|
case _:
|
||||||
case _:
|
return "ERROR"
|
||||||
return "OFFLINE"
|
except:
|
||||||
|
return "OFFLINE"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=False)
|
mode = os.environ['DEBUG_MODE']
|
||||||
|
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>
|
<p><a href="mailto:ahoemann@proton.me">ahoemann@proton.me</a>
|
||||||
© Copyright 2024 by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
</p>Authored by <a href="https://adrianux.net/">Adrian Hoemann</a>.
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue