Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Add health check to Singularity API #164

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The version of singularity you will use to make deals. Generally, this should not change
SINGULARITY_REF=:v0.5.1
SINGULARITY_REF=:v0.5.2

# Comma seperated list of storage providers motion should make storage deals with
# You must set this value to contain at least one storage provider for motion to
Expand All @@ -14,20 +14,20 @@ MOTION_WALLET_KEY=

# This is the domain/IP you will expose publicly to transfer data to storage providers
# When you initialize the singularity docker setup, it will start a server to deliver
# content to storage providers on localhost:7778. However, you will need to either
# content to storage providers on localhost:7778. However, you will need to either
# open this specific port on your firewall, and set this value to http://~your-static-ip~:7778
# or you will need to setup reverse proxying from a dedicated web server like NGinx
SINGULARITY_CONTENT_PROVIDER_DOMAIN=

# Additional configuration parameters, sorted by the likelyhood you will want to set
# custom configuration values on your motion instance. In general, most of these should
# custom configuration values on your motion instance. In general, most of these should
# not need to change.

# Frequency (as a cron tab expression) with which motion should attempt to make
# new Filecoin deals. Defaults to every minute
#MOTION_SINGULARITY_SCHEDULE_CRON="* * * * *"

# Maximum number of deals motion should attempt to make when checking for new deals.
# Maximum number of deals motion should attempt to make when checking for new deals.
# Defaults to 1
#MOTION_SINGULARITY_SCHEDULE_DEAL_NUMBER=1

Expand Down Expand Up @@ -68,7 +68,7 @@ SINGULARITY_CONTENT_PROVIDER_DOMAIN=
# API endpoint
#LOTUS_TOKEN=

# Maximum size of packed CAR files for deals made with singularity.
# Maximum size of packed CAR files for deals made with singularity.
# Defaults to close to 32 gigabytes. You should not need to change this
#MOTION_SINGULARITY_MAX_CAR_SIZE=31.5GiB

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ motion
integration/test/motionlarity/.env.local
integration/test/motionlarity/.up
integration/test/devnet/.up
integration/test/devnet/.boostready
integration/test/devnet/.boostready
63 changes: 63 additions & 0 deletions docker-compose-local-dev-with-singularity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# To use it with a local Singularity instance, you need to make sure you have Singularity cloned in the same directory as motion
# Use below command to run the docker compose
# docker compose -f ./docker-compose-local-dev-with-singularity.yml up --build
# -f specifies the docker compose configuration file
# --build will force rebuilding Singularity or Motion if anything changes in the local code or Dockerfile
version: '3.8'

services:
db:
extends:
file: docker-compose.yml
service: db

singularity_admin_init:
extends:
file: docker-compose.yml
service: singularity_admin_init
build: ../singularity
image: singularity-local

singularity_api:
extends:
file: docker-compose.yml
service: singularity_api
image: singularity-local

singularity_dataset_worker:
extends:
file: docker-compose.yml
service: singularity_dataset_worker
image: singularity-local

singularity_deal_pusher:
extends:
file: docker-compose.yml
service: singularity_deal_pusher
image: singularity-local

singularity_deal_tracker:
extends:
file: docker-compose.yml
service: singularity_deal_tracker
image: singularity-local

singularity_content_provider:
extends:
file: docker-compose.yml
service: singularity_content_provider
image: singularity-local

motion:
extends:
file: docker-compose.yml
service: motion
build: .
image: motion-local

volumes:
motion-singularity-volume:

networks:
default:
name: motion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file is added as as extension? I am curious why not update the docker compose it extends directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the networks section cannot be extended. extension only works for service

53 changes: 9 additions & 44 deletions docker-compose-local-dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Use below command to run the docker compose
# docker compose -f ./docker-compose-local-dev.yml up --build
# -f specifies the docker compose configuration file
# --build will force rebuilding Motion if anything changes in the local code or Dockerfile
version: '3.8'

services:
Expand All @@ -10,81 +14,42 @@ services:
extends:
file: docker-compose.yml
service: singularity_admin_init
depends_on:
db:
condition: service_healthy

singularity_api:
extends:
file: docker-compose.yml
service: singularity_api
depends_on:
singularity_admin_init:
condition: service_completed_successfully

singularity_dataset_worker:
extends:
file: docker-compose.yml
service: singularity_dataset_worker
depends_on:
singularity_admin_init:
condition: service_completed_successfully

singularity_deal_pusher:
extends:
file: docker-compose.yml
service: singularity_deal_pusher
depends_on:
singularity_admin_init:
condition: service_completed_successfully

singularity_deal_tracker:
extends:
file: docker-compose.yml
service: singularity_deal_tracker
depends_on:
singularity_admin_init:
condition: service_completed_successfully

singularity_content_provider:
extends:
file: docker-compose.yml
service: singularity_content_provider
depends_on:
singularity_admin_init:
condition: service_completed_successfully

motion:
extends:
file: docker-compose.yml
service: motion
build: .
entrypoint: motion --experimentalSingularityStore --experimentalRemoteSingularityAPIUrl=singularity_api:9090 --experimentalSingularityContentURLTemplate=${SINGULARITY_CONTENT_PROVIDER_DOMAIN:-http://singularity_content_provider:7778}/piece/{PIECE_CID}
ports:
- 40080:40080
environment:
- MOTION_STORE_DIR=/usr/src/app/storage
- LOTUS_TEST
- LOTUS_API
- LOTUS_TOKEN
- MOTION_STORAGE_PROVIDERS
- MOTION_PRICE_PER_GIB_EPOCH
- MOTION_PRICE_PER_GIB
- MOTION_PRICE_PER_DEAL
- MOTION_DEAL_START_DELAY
- MOTION_DEAL_DURATION
- MOTION_SINGULARITY_MAX_CAR_SIZE
- MOTION_SINGULARITY_PACK_THRESHOLD
- MOTION_SINGULARITY_SCHEDULE_CRON
- MOTION_SINGULARITY_SCHEDULE_DEAL_NUMBER
- MOTION_SINGULARITY_CLEANUP_INTERVAL
- MOTION_WALLET_KEY
- MOTION_VERIFIED_DEAL
volumes:
- motion-singularity-volume:/usr/src/app/storage
depends_on:
- singularity_api
image: motion-local

volumes:
motion-singularity-volume:

networks:
default:
name: motion
name: motion
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
- motion-singularity-volume:/usr/src/app/storage
environment:
DATABASE_CONNECTION_STRING: postgres://${SINGULARITY_DB_USER:-postgres}:${SINGULARITY_DB_PASSWORD:-postgres}@db:5432/${SINGULARITY_DB_NAME:-singularity}
LOTUS_TEST:
LOTUS_TEST:
LOTUS_API:
LOTUS_TOKEN:
depends_on:
Expand All @@ -41,9 +41,14 @@ services:
- 9090:9090
environment:
DATABASE_CONNECTION_STRING: postgres://${SINGULARITY_DB_USER:-postgres}:${SINGULARITY_DB_PASSWORD:-postgres}@db:5432/${SINGULARITY_DB_NAME:-singularity}
LOTUS_TEST:
LOTUS_TEST:
LOTUS_API:
LOTUS_TOKEN:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9090/health"]
interval: 5s
timeout: 5s
retries: 5
depends_on:
singularity_admin_init:
condition: service_completed_successfully
Expand Down
Loading