265 lines
6.4 KiB
Markdown
265 lines
6.4 KiB
Markdown
# Notes de deploiement - OpenSquared PWA
|
|
|
|
Date: 2026-04-26
|
|
|
|
## Depot
|
|
|
|
```text
|
|
https://gitea.open-squared.tech/admin/openbot.git
|
|
branche main
|
|
```
|
|
|
|
Commits importants:
|
|
|
|
```text
|
|
fb8cc4d Initial PWA assistant proof of concept
|
|
94148e8 Rename installed PWA to OpenSquared
|
|
1f815fa Version PWA icon asset to refresh Android cache
|
|
1b9933d Fix voice button audio unlock hang
|
|
```
|
|
|
|
Derniers changements locaux a deployer:
|
|
|
|
```text
|
|
- Service systemd `opensquared-assistant` pour tourner hors session Putty.
|
|
- Raccourci optionnel `/usr/local/bin/openbot`.
|
|
- Mode mains libres: `Demarrer` ecoute en continu, envoi apres 2 secondes de silence.
|
|
- TTS par defaut via voix navigateur `fr-FR` pour eviter l'accent anglais Groq.
|
|
- Voix navigateur adoucie avec preference pour voix feminine francaise.
|
|
- Ajout de contacts email par conversation.
|
|
- Carnet de contacts prod dans `/root/openbot/data/contacts.json`.
|
|
- Memoire professionnelle SQLite dans `/root/openbot/data/memory.sqlite`.
|
|
- Cache PWA: opensquared-assistant-v7.
|
|
```
|
|
|
|
## VPS
|
|
|
|
```text
|
|
Serveur: 46.202.173.47
|
|
Dossier app: /root/openbot
|
|
Domaine: bot.open-squared.tech
|
|
URL: https://bot.open-squared.tech
|
|
```
|
|
|
|
L'app Flask a ete testee sur:
|
|
|
|
```text
|
|
http://46.202.173.47:8080/health
|
|
https://bot.open-squared.tech/health
|
|
```
|
|
|
|
## Python
|
|
|
|
Sur le VPS, `python3 -m venv .venv` a d'abord echoue car `python3.12-venv` manquait.
|
|
|
|
Correctif:
|
|
|
|
```bash
|
|
apt update
|
|
apt install -y python3.12-venv
|
|
cd /root/openbot
|
|
python3 -m venv .venv
|
|
source .venv/bin/activate
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Service systemd
|
|
|
|
Installer ou mettre a jour le service:
|
|
|
|
```bash
|
|
cd /root/openbot
|
|
cp deploy/opensquared-assistant.service /etc/systemd/system/opensquared-assistant.service
|
|
systemctl daemon-reload
|
|
systemctl enable --now opensquared-assistant
|
|
```
|
|
|
|
Commandes quotidiennes:
|
|
|
|
```bash
|
|
systemctl start opensquared-assistant
|
|
systemctl stop opensquared-assistant
|
|
systemctl restart opensquared-assistant
|
|
systemctl status opensquared-assistant
|
|
journalctl -u opensquared-assistant -f
|
|
```
|
|
|
|
Raccourci optionnel:
|
|
|
|
```bash
|
|
install -m 755 /root/openbot/deploy/openbot /usr/local/bin/openbot
|
|
openbot start
|
|
openbot stop
|
|
openbot restart
|
|
openbot logs
|
|
```
|
|
|
|
## HTTPS et Nginx Docker
|
|
|
|
Le VPS utilise deja un `docker-compose.yml` avec un conteneur `nginx`.
|
|
|
|
Montage nginx:
|
|
|
|
```text
|
|
/root/tradon/nginx/conf -> /etc/nginx/conf.d
|
|
/etc/letsencrypt -> /etc/letsencrypt:ro
|
|
/root/tradon/nginx/certbot -> /var/www/certbot
|
|
```
|
|
|
|
Le bloc HTTP doit servir les challenges avant la redirection:
|
|
|
|
```nginx
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
```
|
|
|
|
Certificat cree avec:
|
|
|
|
```bash
|
|
certbot certonly --webroot \
|
|
-w /root/tradon/nginx/certbot \
|
|
-d bot.open-squared.tech
|
|
```
|
|
|
|
Le bloc HTTPS `bot.open-squared.tech` doit utiliser:
|
|
|
|
```nginx
|
|
ssl_certificate /etc/letsencrypt/live/bot.open-squared.tech/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/bot.open-squared.tech/privkey.pem;
|
|
```
|
|
|
|
Proxy depuis nginx Docker vers Flask sur l'hote:
|
|
|
|
```nginx
|
|
proxy_pass http://172.17.0.1:8080;
|
|
```
|
|
|
|
Verifier:
|
|
|
|
```bash
|
|
docker exec nginx nginx -t
|
|
docker exec nginx nginx -s reload
|
|
curl -I https://bot.open-squared.tech/health
|
|
```
|
|
|
|
## PWA Android
|
|
|
|
Nom installe:
|
|
|
|
```text
|
|
OpenSquared
|
|
```
|
|
|
|
Icone:
|
|
|
|
```text
|
|
static/icons/icon-v2.svg
|
|
```
|
|
|
|
Pour forcer Android/Chrome a prendre la nouvelle icone:
|
|
|
|
1. `git pull` sur le VPS.
|
|
2. Ouvrir `https://bot.open-squared.tech/icons/icon-v2.svg`.
|
|
3. Desinstaller l'ancienne PWA.
|
|
4. Reinstaller depuis Chrome.
|
|
|
|
## Cache et bouton micro
|
|
|
|
Le bouton `Demarrer` etait non reactif sur navigateur parce que `unlockAudio()` pouvait rester bloque sur `audio.play()` avec un audio vide.
|
|
|
|
Correctif applique:
|
|
|
|
- `unlockAudio()` utilise maintenant `AudioContext`.
|
|
- `index.html` charge `/app.js?v=5`.
|
|
- Service worker: `opensquared-assistant-v5`.
|
|
- Le bouton `Demarrer` lance le mode mains libres.
|
|
- Le message vocal est envoye automatiquement apres 2 secondes de silence.
|
|
- La voix par defaut est celle du navigateur en `fr-FR`, via `TTS_PROVIDER=browser`.
|
|
- La version v6 privilegie une voix feminine francaise si disponible sur l'appareil.
|
|
- Les contacts peuvent etre ajoutes en disant par exemple: `Ajoute Sophie avec l'adresse sophie@example.com`.
|
|
- Le service systemd definit `CONTACTS_FILE=/root/openbot/data/contacts.json`.
|
|
- La version v7 ajoute une memoire professionnelle SQLite pour clients, projets, taches, notes et depots Git.
|
|
- Le service systemd definit `MEMORY_DB=/root/openbot/data/memory.sqlite`.
|
|
|
|
Si le bouton ne reagit pas apres un deploiement:
|
|
|
|
```text
|
|
PC: Ctrl+F5
|
|
Android: fermer l'app, rouvrir Chrome, ou desinstaller/reinstaller la PWA
|
|
```
|
|
|
|
Si ca persiste, ouvrir F12 -> Console et lire l'erreur JS.
|
|
|
|
## Fin de session - 2026-04-27
|
|
|
|
Etat fonctionnel vise:
|
|
|
|
- L'app ne depend plus d'une session Putty ouverte.
|
|
- `systemd` gere le processus `opensquared-assistant`.
|
|
- Gunicorn lance `app:app` depuis `/root/openbot`.
|
|
- Le bouton `Demarrer` active une ecoute mains libres.
|
|
- Une phrase est transmise automatiquement apres environ 2 secondes de silence.
|
|
- La reponse est lue avec une voix navigateur francaise, adoucie et preferee feminine si disponible.
|
|
- Les contacts email peuvent etre ajoutes par conversation.
|
|
- Les clients, projets, taches, notes et depots Git associes peuvent etre memorises en SQLite.
|
|
|
|
Commits a avoir sur le VPS:
|
|
|
|
```text
|
|
f876b3a Add hands-free PWA mode and systemd service
|
|
94e14a3 Add soft French voice and contact saving
|
|
```
|
|
|
|
Checklist VPS:
|
|
|
|
```bash
|
|
cd /root/openbot
|
|
git pull
|
|
cp deploy/opensquared-assistant.service /etc/systemd/system/opensquared-assistant.service
|
|
systemctl daemon-reload
|
|
systemctl enable --now opensquared-assistant
|
|
install -m 755 deploy/openbot /usr/local/bin/openbot
|
|
openbot restart
|
|
openbot status
|
|
```
|
|
|
|
Commandes utiles:
|
|
|
|
```bash
|
|
openbot start
|
|
openbot stop
|
|
openbot restart
|
|
openbot logs
|
|
systemctl status opensquared-assistant
|
|
journalctl -u opensquared-assistant -f
|
|
```
|
|
|
|
Variables importantes:
|
|
|
|
```text
|
|
TTS_PROVIDER=browser
|
|
CONTACTS_FILE=/root/openbot/data/contacts.json
|
|
MEMORY_DB=/root/openbot/data/memory.sqlite
|
|
```
|
|
|
|
Exemples vocaux:
|
|
|
|
```text
|
|
Ajoute Sophie avec l'adresse sophie@example.com
|
|
Envoie un email a Sophie
|
|
SAFTCO est un nouveau client, note quelque part que je dois rappeler le directeur
|
|
Associe le repo /root/openbot/repos/saftco au projet Portail SAFTCO
|
|
Qu'est-ce que tu sais sur SAFTCO ?
|
|
```
|
|
|
|
Attention cache mobile:
|
|
|
|
- `index.html` charge `/app.js?v=7`.
|
|
- Service worker: `opensquared-assistant-v7`.
|
|
- Si Android garde l'ancien JS, fermer/rouvrir Chrome ou reinstaller la PWA.
|