diff --git a/README.md b/README.md index 8a12d0d8..e0d0a54b 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,25 @@ This is a small program that shows the usage of the [api](https://gitlab.com/ope data from TypeScript code. Feel free to copy the [minimal-connector](https://gitlab.com/openstapps/minimal-connector/) and write your own connector with it. +## Add your connector +You may want to integrate your connectors in the `docker-compose.yml` to +deploy your whole StApps-backend-environment in a single command. Use the +`systemd` directory in this project as an example of how to deploy +your connector(s) and configure `systemd` services and timers. + +The service will try to restart a named container. That means for successful +execution the container needs to be started once before with the appropriate +command. +```shell +docker-compose up minimal-connector +``` + +To enable the service that runs the connector periodically execute: +```shell +systemctl --now enable /absolute/path/minimal-deployment/minimal-connector/minimal-connector.service /absolute/path/minimal-deployment/minimal-connector/minimal-connector.timer +``` +This command will immediately start the service on execution. + ## Round off your deployment with the [proxy](https://gitlab.com/openstapps/proxy) The backend is exposed on the port 3000 now. This means anyone can import data into your backend and you can only run one version of the backend at a time. Have a look at the [proxy](https://gitlab.com/openstapps/proxy/) to secure and diff --git a/docker-compose.yml b/docker-compose.yml index d35ee5da..3ee2b47c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,3 +32,7 @@ services: links: - "backend" + minimal-connector: + image: registry.gitlab.com/openstapps/minimal-connector:core-0.23 + container_name: minimal-connector-0.23 + command: ["http://backend:3000", "minimal-connector", "f-u"] diff --git a/start.sh b/start.sh index 98980d39..2873137c 100755 --- a/start.sh +++ b/start.sh @@ -52,6 +52,11 @@ Useful commands: * In case you don't need the containers to be running anymore, you can also stop them using docker-compose command (example for database container): $SUDO docker-compose stop database + +* If you want to test the functionality of the "minimal-connector", use the following command. + + $SUDO docker-compose up minimal-connector + EOF read _ diff --git a/systemd/minimal-connector.service b/systemd/minimal-connector.service new file mode 100644 index 00000000..bc92ea9e --- /dev/null +++ b/systemd/minimal-connector.service @@ -0,0 +1,10 @@ +[Unit] +Description=Restarts the "minimal-connector-0.23" container + +[Service] +Type=oneshot +User=root +ExecStart=/usr/bin/env docker restart minimal-connector-0.23 + +[Install] +WantedBy=multi-user.target diff --git a/systemd/minimal-connector.timer b/systemd/minimal-connector.timer new file mode 100644 index 00000000..ff2de4ee --- /dev/null +++ b/systemd/minimal-connector.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run the minimal-connector.service every 5 minutes. If you need other timer configurations, please refer to: https://wiki.archlinux.org/index.php/Systemd/Timers + +[Timer] +OnCalendar=*:0/5 + +[Install] +WantedBy=timers.target