|
|
| Line 101: |
Line 101: |
| | | |
| # curl -i -X POST "https://entorb.net/strava-be/activityStats2/" -H "Content-Type: application/json" -d '{"sessionId": "1234"}' | | # curl -i -X POST "https://entorb.net/strava-be/activityStats2/" -H "Content-Type: application/json" -d '{"sessionId": "1234"}' |
|
| |
| ==Checkliste neuer U7 Account==
| |
| ~/.bashrc und ~/.bash_profile von altem angeglichen
| |
| Logs aktiviert
| |
| uberspace web log access enable
| |
| uberspace web log apache_error enable
| |
| uberspace web log php_error enable
| |
| uberspace web errorpage 500 disable
| |
|
| |
| ==Probleme bei der Migration Uberspace U6 zu U7==
| |
| ===0. E-Mails===
| |
| Es scheinen keine E-Mails mehr rein und raus zu gehen. (Account xxx@entorb.net).
| |
|
| |
| Neuer Webmailer ist https://webmail.uberspace.de , dieser zeigt aber erst nach Abschluss der Migration auf das neue Postfach. Solange die Migration nicht abgeschlossen ist, muss im Mail Client (wie Thunderbird) dieser Login für den U7 Mail Account verwendet werden:
| |
| statt xxx@entorb.net -> xxx@entorb.uber.space
| |
|
| |
| ===1. HTTPS Zertifikat===
| |
| HTTPS Zertifikat war auf einmal nicht mehr gültig für https://www.entorb.net . Das hatte erst auch auf dem U7 funktioniert, nun plötzlich nicht mehr. UPDATE: Problem verschwand von alleine, hing vielleicht mit dem DNS Umzug zusammen.
| |
|
| |
| ===2. bestehende ezmlm Mailinglisten===
| |
| ezmlm ist gemäß [https://lab.uberspace.de/guide_ezmlm.html Anleitung] installiert, allerdings sagt mir
| |
| ezmlm-make -+ ~/ezmlm/oldlist ~/.qmail-oldlist oldlist entorb.uber.space
| |
| > ezmlm-make: fatal: unable to stat /etc/ezmlm/de: file does not exist
| |
|
| |
| Wenn ich hingegen testweise einen neuen Verteiler anlege tut es:
| |
| ezmlm-make -A -u -m -5 xxx@entorb.net ~/ezmlm/mylist ~/.qmail-mylist
| |
| mylist entorb.uber.space
| |
| und diesen kann ich dann auch bearbeiten via
| |
| ezmlm-make -+ ~/ezmlm/mylist ~/.qmail-mylist mylist entorb.uber.space
| |
|
| |
| Lösung:
| |
| in ezmlm/oldlist/ezmlmrc die entsprechende Zeile löschen
| |
|
| |
| ===3. Zugriff auf Dateien außerhab von ~/html===
| |
| Ich hatte einige Dateien (wie zB eine sqlite DB) in meinem Home (~/) liegen. Auf diese sollen Skripte die sich unter
| |
| ~/html->/var/www/virtual/entorb/html
| |
| befinden zugreifen können. Das funktionierte nicht mehr, da SELinux hier rein grätscht
| |
|
| |
| Beste Lösung: Die Dateien auf die der httpd zugreifen soll nach
| |
| /var/www/virtual/entorb/
| |
| verschieben und im Home Symlink hinterlassen.
| |
|
| |
| Erster Ansatz: der SELinux Kontexte lässt sich so setzen (Siehe [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/sect-security-enhanced_linux-working_with_selinux-selinux_contexts_labeling_files]
| |
| ).
| |
| chcon -t httpd_sys_content_t file-name
| |
| half hier aber nicht:
| |
| ls -laZ /home/ |grep ento
| |
| drwx------. entorb entorb unconfined_u:object_r:user_home_dir_t:s0 entorb
| |
|
| |
| ===4. Perl Module, wie zB Excel::Writer::XLSX===
| |
| Installiert via
| |
| cpanm Excel::Writer::XLSX
| |
|
| |
| Führe ich das Skript ~/html/test.pl in der Shell aus, wird das Modul
| |
| gefunden und geladen. Im Browser via https://entorb.net/test.pl wird
| |
| das Modul nicht gefunden.
| |
|
| |
| Ursache 4.1 war dass SELinux den Zugriff des httpd auf /home/entorb/perl5 blockierte
| |
|
| |
| Lösung:
| |
| ~/perl5 Verzeichnis nach
| |
| /var/www/virtual/entorb/perl5
| |
| verschoben und im Home einen Symlink hinterlassen.
| |
|
| |
| Dann zuerst lib::local installiert, dann andere Module.
| |
|
| |
| Ursache 4.2 war dass ich in der .bashrc dies gesetzt habe:
| |
| eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)
| |
| das musste ich im Perl Skript ebenfalls hinterlegen:
| |
| use lib ('/var/www/virtual/entorb/perl5/lib/perl5');
| |
| # aber !kein! use local::lib; !!!
| |
|
| |
| ===5. sendmail===
| |
| ich stellte fest, dass ich im U7 aus Python oder Perl CGI Skripten nicht mehr auf sendmail zugreifen kann. Über die Shell kommt die Mail sofort an. Beispiel:
| |
| 8<---
| |
| import os
| |
| SENDMAIL = "/usr/sbin/sendmail"
| |
| to = "xxx@entorb.net"
| |
| subject = "testmail"
| |
| sender = "U7 <no-reply@entorb.net>"
| |
| body = "leer"
| |
| mail = f"To: {to}\nSubject: {subject}\nFrom: {sender}\nContent-Type:
| |
| text/plain; charset=\"utf-8\"\n\n{body}"
| |
| p = os.popen(f"{SENDMAIL} -t -i", "w")
| |
| p.write(mail)
| |
| p.close()
| |
| 8<---
| |
| Lösung: statt Versand aus Web-Skripten/Seiten via sendmail, besser aus den Skripten ein Insert in eine SQLite DB machen und diese via cronjob und php mail() Funktion periodisch abarbeiten.
| |
|
| |
| ===6. Wiederholung der Migration===
| |
| Entweder einfach Migration auf dem U6 nochmal starten via
| |
| uberspace-move-account -u entorb
| |
| oder in Dashboard den Umzug abbrechen und neu starten -> anderer Server.
| |
|
| |
| ===7. MySQL DB Passwort angeblich zu kurz===
| |
| Das Migrationsskript hatte behauptet, dass mein MySQL Passwort zu kurz sei. Stimmte nicht, vermutlich kam es mit den Sonderzeichen durcheinander. Habe daher ein neues langes ohne Sonderzeichen vergeben.
| |
|
| |
|
| ==Streamlit== | | ==Streamlit== |
Manuals
https://manual.uberspace.de and https://lab.uberspace.de
PHP
see https://manual.uberspace.de/lang-php/
to restart
uberspace tools restart php
php-fpm
less /opt/uberspace/etc/$USER/php-fpm.conf
Python FastAPI
see https://lab.uberspace.de/guide_fastapi/
# var 1: venv
python3.11 -m venv venv
source venv/bin/activate
pip install fastapi uvicorn
pip install fastapi.responses
pip install gunicorn uvloop httptools
deactivate
# var 2: not use venv
pip3.11 install --user fastapi uvicorn fastapi.responses gunicorn uvloop httptools
# config backend
uberspace web backend set /strava-be --http --port 9001
# --remove-prefix
uberspace web backend list
supervisorctl restart fastapi
~/fastapi/conf.py
#!/usr/bin/env python3.10
# apply changes via
# supervisorctl restart fastapi
import os
app_path = os.environ["HOME"] + "/fastapi"
# Gunicorn configuration
wsgi_app = "main:api"
bind = ":9001"
chdir = app_path
workers = 1
worker_class = "uvicorn.workers.UvicornWorker"
# errorlog = app_path + "/errors.log"
# accesslog = app_path + "/access.log"
~/fastapi/main.py
#!/usr/bin/env python3.10
# apply changes via
# supervisorctl restart fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from pydantic import BaseModel
import subprocess
class StravaSession(BaseModel):
sessionId: str
api = FastAPI()
@api.post("/strava-be/activityStats2/")
async def activityStats2(session: StravaSession):
# return {session}
response = {}
# response = {"session": session.sessionId}
process = subprocess.run(
[
"python3.10",
"/var/www/virtual/entorb/html/strava/activityStats2.py",
session.sessionId,
],
capture_output=True,
)
if process.returncode == 0:
response["status"] = "ok"
response_code = 200
# response["process_stdout"] = process.stdout.decode()
else:
response["status"] = "error"
response_code = 400
# response["process_stdout"] = process.stdout.decode()
response["error_message"] = process.stderr.decode()
return JSONResponse(content=response, status_code=response_code)
# To test this app locally, uncomment:
# import uvicorn
# uvicorn.run(api, host="localhost", port=8001)
# curl -i -X POST "https://entorb.net/strava-be/activityStats2/" -H "Content-Type: application/json" -d '{"sessionId": "1234"}'
Streamlit
see also strava-streamlit readme
Installation
pip3.11 install --user streamlit
Setup dir and config
mkdir ~/strava-streamlit
cd ~/strava-streamlit
mkdir .streamlit
vim .streamlit/config.toml
[browser]
gatherUsageStats = false
[server]
headless = true
port = 8501
baseUrlPath = "/strava-streamlit"
baseUrlPath is important when not running in web server document root
create minimal Streamlit app
vim src/app.py
import streamlit as st
st.title("Test")
start it manually as testrun (stop by ctrl+c)
streamlit run src/app.py
Add web backend
uberspace web backend set /strava-streamlit --http --port 8501
maybe add --remove-prefix
Access it via browser
https://entorb.net/strava-streamlit
Create Service
vim ~/etc/services.d/streamlit-strava.ini
[program:streamlit-strava]
directory=%(ENV_HOME)s/be/strava-streamlit
command=python3.11 -O -m streamlit run src/app.py
# for env var:
environment=MY_VAR="asdf"
loglevel=info
Start Service
supervisorctl reread
supervisorctl update
supervisorctl status
supervisorctl restart strava-streamlit
Check log
supervisorctl tail -f strava-streamlit
# as this is empty:
tail -f ~/logs/supervisord.log