Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsm-orchestration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UFZ TSM
tsm-orchestration
Commits
7c1bd897
Commit
7c1bd897
authored
1 month ago
by
Florian Gransee
Committed by
Bert Palm
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
thing abstraction for crontab setup
parent
c50dcdce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!290
C itest
,
!289
some generic fixes and cleanup
,
!283
492 add thing abstraction to services
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker-compose.yml
+7
-1
7 additions, 1 deletion
docker-compose.yml
src/setup_crontab.py
+5
-3
5 additions, 3 deletions
src/setup_crontab.py
with
12 additions
and
4 deletions
docker-compose.yml
+
7
−
1
View file @
7c1bd897
...
...
@@ -828,7 +828,7 @@ services:
condition
:
service_healthy
environment
:
LOG_LEVEL
:
"
${LOG_LEVEL}"
TOPIC
:
thing_creation
TOPIC
:
configdb_update
MQTT_BROKER
:
mqtt-broker:1883
MQTT_USER
:
"
${MQTT_USER}"
MQTT_PASSWORD
:
"
${MQTT_PASSWORD}"
...
...
@@ -837,6 +837,12 @@ services:
MQTT_QOS
:
"
${MQTT_QOS}"
DB_API_BASE_URL
:
"
${DB_API_BASE_URL}"
JOURNALING
:
"
${JOURNALING}"
CONFIGDB_DSN
:
"
postgresql://
\
${CONFIGDB_USER}:
\
${CONFIGDB_PASSWORD}@
\
${CONFIGDB_HOST}:
\
${CONFIGDB_PORT}/
\
${CONFIGDB_DB}"
entrypoint
:
[
"
python3"
,
"
setup_crontab.py"
]
volumes
:
-
./cron/crontab.txt:/tmp/cron/crontab.txt
...
...
This diff is collapsed.
Click to expand it.
src/setup_crontab.py
+
5
−
3
View file @
7c1bd897
...
...
@@ -7,9 +7,10 @@ from random import randint
from
crontab
import
CronItem
,
CronTab
from
timeio.mqtt
import
AbstractHandler
,
MQTTMessage
from
timeio.
thing
import
Thing
from
timeio.
feta
import
Thing
from
timeio.common
import
get_envvar
,
setup_logging
from
timeio.journaling
import
Journal
from
timeio.typehints
import
MqttPayload
logger
=
logging
.
getLogger
(
"
crontab-setup
"
)
journal
=
Journal
(
"
Cron
"
)
...
...
@@ -27,9 +28,10 @@ class CreateThingInCrontabHandler(AbstractHandler):
mqtt_clean_session
=
get_envvar
(
"
MQTT_CLEAN_SESSION
"
,
cast_to
=
bool
),
)
self
.
tabfile
=
"
/tmp/cron/crontab.txt
"
self
.
configdb_dsn
=
get_envvar
(
"
CONFIGDB_DSN
"
)
def
act
(
self
,
content
:
dict
,
message
:
MQTTMessage
):
thing
=
Thing
.
get_instance
(
content
)
def
act
(
self
,
content
:
MqttPayload
.
ConfigDBUpdate
,
message
:
MQTTMessage
):
thing
=
Thing
.
from_uuid
(
content
[
"
thing
"
],
dsn
=
self
.
configdb_dsn
)
with
CronTab
(
tabfile
=
self
.
tabfile
)
as
crontab
:
for
job
in
crontab
:
if
self
.
job_belongs_to_thing
(
job
,
thing
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment