Skip to content
Snippets Groups Projects
Commit 37baeaf4 authored by Joost Hemmen's avatar Joost Hemmen :basketball:
Browse files

Merge branch '95-wrong-path-to-sftp-sync-job' into 'main'

Resolve "wrong path in cv sync job"

Closes #95

See merge request !152
parents 8559ebb6 2ef3799b
No related branches found
No related tags found
1 merge request!152Resolve "wrong path in cv sync job"
Pipeline #385679 passed
...@@ -14,3 +14,4 @@ data/ ...@@ -14,3 +14,4 @@ data/
!data/tomcat/context/.gitkeep !data/tomcat/context/.gitkeep
/Pipfile /Pipfile
docker-compose-dev.yml docker-compose-dev.yml
cron/crontab.txt
30 1-23/3 * * * /scripts/sms_sync/sms_cv_tables.py > $STDOUT 2>$STDERR
15,45 * * * * /usr/bin/python3 /scripts/sms_sync/sms_cv_tables.py > $STDOUT 2>$STDERR
#!/usr/bin/python3
from sync_utils import ( from sync_utils import (
create_table, create_table,
upsert_table, upsert_table,
get_connection_from_env, get_connection_from_env,
) )
from os import chdir, environ import os
import json import json
url = environ.get("CV_API_URL") script_dir = os.path.dirname(os.path.abspath(__file__))
home = environ.get("HOME")
chdir(home) file_names = [
"sms_cv_measured_quantity.json"
]
file_path_list = ["scripts/sms_sync/tables/sms_cv_measured_quantity.json"] file_path_list = [os.path.join(script_dir, "tables", file_name) for file_name in file_names]
if __name__ == "__main__": if __name__ == "__main__":
url = os.environ.get("CV_API_URL")
home = os.environ.get("HOME")
os.chdir(home)
for file_path in file_path_list: for file_path in file_path_list:
db = get_connection_from_env() db = get_connection_from_env()
try: try:
......
...@@ -25,6 +25,7 @@ services: ...@@ -25,6 +25,7 @@ services:
volumes: volumes:
- "./data/minio/certs/:/tmp/certs" - "./data/minio/certs/:/tmp/certs"
- "./nginx/html/:/home/tsm/html" - "./nginx/html/:/home/tsm/html"
- "./cron:/tmp/cron"
# Summary # Summary
...@@ -697,6 +698,8 @@ services: ...@@ -697,6 +698,8 @@ services:
depends_on: depends_on:
mqtt-broker: mqtt-broker:
condition: "service_healthy" condition: "service_healthy"
init:
condition: "service_completed_successfully"
environment: environment:
LOG_LEVEL: "${LOG_LEVEL}" LOG_LEVEL: "${LOG_LEVEL}"
TOPIC: "thing_creation" TOPIC: "thing_creation"
...@@ -791,6 +794,9 @@ services: ...@@ -791,6 +794,9 @@ services:
${FRONTEND_POSTGRES_PASS}@\ ${FRONTEND_POSTGRES_PASS}@\
${FRONTEND_POSTGRES_HOST}/\ ${FRONTEND_POSTGRES_HOST}/\
${FRONTEND_POSTGRES_DB}" ${FRONTEND_POSTGRES_DB}"
depends_on:
init:
condition: "service_completed_successfully"
healthcheck: healthcheck:
test: [ "CMD-SHELL", "service cron status || exit 1" ] test: [ "CMD-SHELL", "service cron status || exit 1" ]
interval: 5s interval: 5s
......
...@@ -22,4 +22,10 @@ chmod a+x /home/tsm/html/css ...@@ -22,4 +22,10 @@ chmod a+x /home/tsm/html/css
chmod a+x /home/tsm/html/images chmod a+x /home/tsm/html/images
chmod -R a+r /home/tsm/html chmod -R a+r /home/tsm/html
tree -pugfi /home/tsm/html tree -pugfi /home/tsm/html
\ No newline at end of file
# Create crontab.txt if it not already exists
if [ ! -f "/tmp/cron/crontab.txt" ]; then
touch "/tmp/cron/crontab.txt"
chmod 666 "/tmp/cron/crontab.txt"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment