Skip to main content
Glama
si-service-state3.34 kB
--- schemaVersion: "2.2" description: "Run an binary service action, either stop, start or upgrade" parameters: Service: type: "String" description: "Service to Run on Node" default: "N/A" Environment: type: "String" description: "Environment to run in" default: "N/A" InstanceId: type: "String" description: "InstanceId of the executing Node" default: "N/A" Action: type: "String" description: "Action to execute on the Node" default: "N/A" mainSteps: - action: "aws:runShellScript" name: "example" inputs: runCommand: - | case "{{ Action }}" in "down") service {{ Service }} stop echo "{\"instance_id\": \"{{ InstanceId }}\", \"status\": \"success\", \"service\": \"{{ Service }}\", \"state\": \"{{ Action }}\" }" ;; "up") service {{ Service }} restart echo "{\"instance_id\": \"{{ InstanceId }}\", \"status\": \"success\", \"service\": \"{{ Service }}\", \"state\": \"{{ Action }}\" }" ;; "upgrade") export SI_SERVICE={{ Service }} export SI_HOSTENV={{ Environment }} export SI_VERSION=$(aws ssm get-parameter --query "Parameter.Value" --output text --name "$SI_HOSTENV-si-version-$SI_SERVICE") export SI_ARTIFACT_TYPE=$(aws ssm get-parameter --query "Parameter.Value" --output text --name "$SI_HOSTENV-binary-type") docker-compose -f /run/app/docker-compose.yaml --profile $SI_SERVICE down -v & docker-compose -f /run/app/docker-compose.yaml --profile $SI_SERVICE pull & wait docker-compose -f /run/app/docker-compose.yaml --profile $SI_SERVICE up --wait wget --no-verbose https://artifacts.systeminit.com/{{ Service }}/${SI_VERSION}/${SI_ARTIFACT_TYPE}/linux/$(arch)/{{ Service }}-${SI_VERSION}-${SI_ARTIFACT_TYPE}-linux-$(arch).tar.gz -O - | tar -xzf - -C / if [ -f "/usr/local/share/{{ Service }}/metadata.json" ]; then METADATA=$(cat /usr/local/share/{{ Service }}/metadata.json | jq) else METADATA=$(sudo find / -wholename '/etc/nix-omnibus/{{ Service }}/**/metadata.json' | tail -n 1 | xargs cat | jq) fi COMMIT=$(echo $METADATA | jq -r '.commit') RUNNING_VERSION=$(echo $METADATA | jq -r '.version') HONEYCOMB_API_KEY=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id ${SI_HOSTENV}-honeycomb-api-key | jq -r '.SecretString') curl https://api.honeycomb.io/1/markers/$SI_SERVICE -X POST \ -H "X-Honeycomb-Team: $HONEYCOMB_API_KEY" \ -d '{"message":" '"$SI_SERVICE replica deployed! Commit: $COMMIT Version: $RUNNING_VERSION"' ", "type":"deploy"}' echo "{\"instance_id\": \"{{ InstanceId }}\", \"status\": \"success\", \"service\": \"{{ Service }}\", \"running\": \"$RUNNING_VERSION\", \"desired_version\": \"$SI_VERSION\" }" ;; *) echo "{\"instance_id\": \"{{ InstanceId }}\", \"status\": \"error\", \"message\": \"Failed to execute action {{ Action }}, not supported.\"}" ;; esac

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server