Skip to content

Commit f8dfb37

Browse files
committed
Add frontend restart to service file, add check for custom db uri
1 parent f1088b6 commit f8dfb37

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

install/mycodo.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ StartLimitBurst=5
66

77
[Service]
88
Restart=on-failure
9-
RestartSec=20s
9+
RestartSec=20
1010
TimeoutSec=0
1111
ExecStart=/opt/Mycodo/env/bin/python /opt/Mycodo/mycodo/mycodo_daemon.py
1212
ExecStop=/opt/Mycodo/env/bin/python /opt/Mycodo/mycodo/mycodo_client.py -t

install/mycodoflask.service

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
[Unit]
22
Description=Mycodo web user interface
33
After=network.target
4+
StartLimitIntervalSec=300
5+
StartLimitBurst=5
46

57
[Service]
8+
Restart=on-failure
9+
RestartSec=20
610
User=root
711
Group=mycodo
812
WorkingDirectory=/opt/Mycodo/mycodo

mycodo/databases/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ def session_scope(db_uri):
1616
Session = sessionmaker()
1717

1818
# later, we create the engine
19-
engine = create_engine(f"{db_uri}?check_same_thread=False")
19+
try:
20+
# Custom URI
21+
from mycodo.config_override import SQLALCHEMY_DATABASE_URI
22+
engine_url = SQLALCHEMY_DATABASE_URI
23+
except:
24+
# SQLite3
25+
engine_url = f"{db_uri}?check_same_thread=False"
26+
27+
engine = create_engine(engine_url)
2028

2129
# associate it with our custom Session class
2230
Session.configure(bind=engine)

0 commit comments

Comments
 (0)