forked from ScoDoc/ScoDoc
controle de la config, doc, exemple .env
This commit is contained in:
parent
98ce5de732
commit
698e5b7e22
20
.env-exemple
Normal file
20
.env-exemple
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Fichier à configurer et renommer en .env
|
||||||
|
# (dans /opt/scodoc)
|
||||||
|
# Il doit appartenir à (ou être lisible par) "scodoc"
|
||||||
|
|
||||||
|
|
||||||
|
FLASK_APP=scodoc.py
|
||||||
|
FLASK_ENV=production # ou "development" si vous développez
|
||||||
|
|
||||||
|
# Envois de mails: décommenter et adapter
|
||||||
|
# MAIL_SERVER=localhost
|
||||||
|
# MAIL_PORT=25
|
||||||
|
|
||||||
|
SCODOC_ADMIN_MAIL="emmanuel@viennet.net"
|
||||||
|
|
||||||
|
# Remplacer cette chaine
|
||||||
|
# Vous pouvez utiliser
|
||||||
|
# python3 -c "import uuid; print(uuid.uuid4().hex)"
|
||||||
|
# pour en créer une de ce genre, aléatoire
|
||||||
|
SECRET_KEY="53ffeff44a3940dea4964d628af33dd9"
|
||||||
|
|
11
README.md
11
README.md
@ -110,15 +110,20 @@ qui est lu automatiquement au démarrage:
|
|||||||
# .env for ScoDoc _development_
|
# .env for ScoDoc _development_
|
||||||
|
|
||||||
FLASK_APP=scodoc.py
|
FLASK_APP=scodoc.py
|
||||||
FLASK_ENV=development
|
FLASK_ENV=development # ou production
|
||||||
|
|
||||||
MAIL_SERVER=votre.serveur.de.mail.net # ou vide si pas de mail
|
MAIL_SERVER=votre.serveur.de.mail.net # ou vide si pas de mail
|
||||||
MAIL_PORT=25
|
MAIL_PORT=25
|
||||||
|
|
||||||
SCODOC_ADMIN_MAIL="adresse.admin@toto.fr" # important: le mail de admin
|
SCODOC_ADMIN_MAIL="adresse.admin@toto.fr" # important: le mail de admin
|
||||||
SECRET_KEY="CGGAJAKlh6789JJK?KNAb=" # une chaine aléatoire
|
SECRET_KEY="CGGAJAKlh6789JJK?KNAb=" # une chaine aléatoire
|
||||||
# comment out to use CDN:
|
|
||||||
BOOTSTRAP_SERVE_LOCAL=1
|
Le fichier `/opt/scodoc/.env-exemple`est donné à titre... d'exemple. Vous pouvez faire:
|
||||||
|
|
||||||
|
# en tant qu'utilisateur scodoc
|
||||||
|
cd /opt/scodoc/
|
||||||
|
cp .env-exemple .env
|
||||||
|
nano .env # édition
|
||||||
|
|
||||||
### Initialisation de la base utilisateur par Flask
|
### Initialisation de la base utilisateur par Flask
|
||||||
|
|
||||||
|
12
config.py
12
config.py
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: UTF-8 -*
|
# -*- coding: UTF-8 -*
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
BASEDIR = os.path.abspath(os.path.dirname(__file__))
|
BASEDIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
@ -10,7 +11,7 @@ load_dotenv(os.path.join(BASEDIR, ".env"))
|
|||||||
class Config:
|
class Config:
|
||||||
"""General configuration. Mostly loaded from environment via .env"""
|
"""General configuration. Mostly loaded from environment via .env"""
|
||||||
|
|
||||||
SECRET_KEY = os.environ.get("SECRET_KEY") or "un-grand-secret-introuvable"
|
SECRET_KEY = os.environ.get("SECRET_KEY") or "90e01e75831e4176a3c70d29564b425f"
|
||||||
SQLALCHEMY_DATABASE_URI = (
|
SQLALCHEMY_DATABASE_URI = (
|
||||||
os.environ.get("USERS_DATABASE_URI")
|
os.environ.get("USERS_DATABASE_URI")
|
||||||
or "postgresql://scodoc@localhost:5432/SCO8USERS"
|
or "postgresql://scodoc@localhost:5432/SCO8USERS"
|
||||||
@ -63,3 +64,12 @@ class TestConfig(DevConfig):
|
|||||||
)
|
)
|
||||||
SERVER_NAME = "test.gr"
|
SERVER_NAME = "test.gr"
|
||||||
DEPT_TEST = "TEST_" # nom du département, ne pas l'utiliser pour un "vrai"
|
DEPT_TEST = "TEST_" # nom du département, ne pas l'utiliser pour un "vrai"
|
||||||
|
|
||||||
|
|
||||||
|
mode = os.environ.get("FLASK_ENV", "production")
|
||||||
|
if mode == "production":
|
||||||
|
RunningConfig = ProdConfig
|
||||||
|
elif mode == "development":
|
||||||
|
RunningConfig = DevConfig
|
||||||
|
elif mode == "test":
|
||||||
|
RunningConfig = TestConfig
|
||||||
|
@ -27,9 +27,9 @@ from app.models import ScoPreference
|
|||||||
from app.views import notes, scolar, absences
|
from app.views import notes, scolar, absences
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
from config import DevConfig
|
from config import RunningConfig
|
||||||
|
|
||||||
app = create_app(DevConfig)
|
app = create_app(RunningConfig)
|
||||||
cli.register(app)
|
cli.register(app)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
# ScoDoc7 service
|
|
||||||
# Zope based
|
|
||||||
# Depends on {{postgresql}} (replaced by installation script by
|
|
||||||
# postgresql@11-main.service on Debian 10
|
|
||||||
# postgresql on Debian <= 9
|
|
||||||
# => is restarted when {{postgresql}} restarts
|
|
||||||
#
|
|
||||||
[Unit]
|
|
||||||
Description=ScoDoc 7 service
|
|
||||||
After=network.target {{postgresql}}
|
|
||||||
Requires={{postgresql}}
|
|
||||||
PartOf={{postgresql}}
|
|
||||||
StartLimitIntervalSec=0
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=forking
|
|
||||||
PIDFile=/opt/scodoc/var/Z2.pid
|
|
||||||
Restart=always
|
|
||||||
RestartSec=1
|
|
||||||
User=root
|
|
||||||
ExecStart=/opt/scodoc/bin/zopectl start
|
|
||||||
ExecStop=/opt/scodoc/bin/zopectl stop
|
|
||||||
ExecReload=/opt/scodoc/bin/zopectl restart
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy={{postgresql}}
|
|
22
tools/etc/scodoc9.service
Normal file
22
tools/etc/scodoc9.service
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# ScoDoc 9 systemd service
|
||||||
|
# Flask based
|
||||||
|
# a priori on ne dépend plus de postgresql ? XXX
|
||||||
|
# inspiré par https://blog.miguelgrinberg.com/post/running-a-flask-application-as-a-service-with-systemd
|
||||||
|
[Unit]
|
||||||
|
Description=ScoDoc 9 service
|
||||||
|
After=network.target
|
||||||
|
#Requires={{postgresql}}
|
||||||
|
#PartOf={{postgresql}}
|
||||||
|
#StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=scodoc
|
||||||
|
Group=scodoc
|
||||||
|
WorkingDirectory=/opt/scodoc
|
||||||
|
ExecStart=/opt/scodoc/venv/bin/gunicorn -b localhost:8000 -w 4 scodoc:app
|
||||||
|
Restart=always
|
||||||
|
# Environment=FLASK_CONFIG=production
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user