Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ RABBITMQ_VIRTUALHOST=omotes

POSTGRES_ROOT_USER=root
POSTGRES_ROOT_PASSWORD=1234
POSTGRES_DEV_PORT=7432
POSTGRES_DATABASE=omotes_rest
POSTGRES_HOST=localhost
POSTGRES_PORT=7432
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ First, change directory: `cd src/`
- Perform all revisions: `alembic upgrade head`
- Downgrade to a revision: `alembic downgrade <revision>` (revision 'base' to
undo everything.)

## Monitoring job runs

A SQL script can be applied optionally to monitor omotes job runs. More details see [Monitoring_job_runs](/doc/Monitoring_job_runs.md)
39 changes: 39 additions & 0 deletions doc/Monitoring_job_runs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Introduction

To monitor OMOTES job runs in a single table. The script below can be applied manually in OMOTES REST PostgreSQL database.

```sql
CREATE TABLE job_logs (
LIKE job_rest INCLUDING DEFAULTS,
deleted_at TIMESTAMP DEFAULT NULL
);

CREATE OR REPLACE FUNCTION backup_job_to_logs()
RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'DELETE' THEN
-- On DELETE: remove existing log row (if any), then insert with deleted_at
DELETE FROM job_logs WHERE job_id = OLD.job_id;

INSERT INTO job_logs
SELECT OLD.*, now();

RETURN OLD;

ELSE
-- On INSERT or UPDATE: remove existing log row (if any), then insert new
DELETE FROM job_logs WHERE job_id = NEW.job_id;

INSERT INTO job_logs
SELECT NEW.*, NULL;

RETURN NEW;
END IF;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER trigger_backup_all
AFTER INSERT OR UPDATE OR DELETE ON job_rest
FOR EACH ROW
EXECUTE FUNCTION backup_job_to_logs();
```
4 changes: 0 additions & 4 deletions docker-compose.override.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ services:
build:
context: ..
dockerfile: omotes-rest/dev.Dockerfile

rest_postgres_db:
ports:
- "${POSTGRES_PORT}:5432"
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
networks:
omotes:
external: true
# mapeditor-net:
# external: true
mapeditor-net:
external: true

volumes:
db-data:
Expand All @@ -12,7 +12,7 @@ services:
image: ghcr.io/project-omotes/omotes_rest:1.2.0
networks:
- omotes
# - mapeditor-net
- mapeditor-net
ports:
- "9200:9200"
environment:
Expand Down Expand Up @@ -46,6 +46,8 @@ services:
- "./src/postgres-init.sql:/setup/init.sql"
networks:
- omotes
ports:
- "${POSTGRES_PORT}:5432"
environment:
PGDATA: /var/lib/POSTGRES/data
POSTGRES_DB: ${POSTGRES_DATABASE}
Expand Down