Change your Node.js code to check an environment variable which tells it what to query.
Example environment variable setting.
export QUERY_TYPE='EMPLOYEE'
or export QUERY_TYPE='STAFF'
In your code retrieve the environment variable QUERY_TYPE.
If QUERY_TYPE=‘EMPLOYEE’ then your code queries employee every 5 minutes.
If QUERY_TYPE=‘STAFF’ then your code queries staff every 10 mins.
Then create a docker-compose.file with 2 services. You will need to add any other options you may need to the docker-compose.yml file (i.e. volumes, other environment variables, etc).
version: '3.4'
services:
employee:
image: your-docker-image-containing your code
environment:
- QUERY_TYPE='EMPLOYEE'
staff:
image: your-docker-image-containing your code
environment:
- QUERY_TYPE='STAFF'
Deploy this as a stack with Docker swarm.
Example:
Docker will start another container if a container fails automatically.
If you don’t run Docker Swarm, then you can add a restart: always to each service in the docker-compose.yml file and run docker-compose up -d. Docker will restart the containers if they fail.