Skip to content

Commit

Permalink
[messages] select not more 100 pending messages
Browse files Browse the repository at this point in the history
[deploy] update memory limit
  • Loading branch information
capcom6 committed Sep 24, 2024
1 parent 41d6534 commit 3a2cd96
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
working-directory: deployments/docker-swarm-terraform
env:
CPU_LIMIT: ${{ vars.CPU_LIMIT }}
MEMORY_LIMIT: ${{ vars.MEMORY_LIMIT }}
run: |
eval "$(ssh-agent -s)"
ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}")
Expand All @@ -54,4 +53,5 @@ jobs:
-var "app-version=${{ needs.build.outputs.app-version }}" \
-var 'app-host=${{ secrets.APP_HOST }}' \
-var "app-config-b64=${{ secrets.APP_CONFIG_B64 }}" \
-var "app-env-json-b64=${{ secrets.APP_ENV_JSON_B64 }}"
-var "app-env-json-b64=${{ secrets.APP_ENV_JSON_B64 }}" \
-var "memory-limit=${{ vars.MEMORY_LIMIT }}"
2 changes: 1 addition & 1 deletion deployments/docker-swarm-terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ resource "docker_service" "app" {
}

reservation {
memory_bytes = 16 * 1024 * 1024
memory_bytes = 32 * 1024 * 1024
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion deployments/docker-swarm-terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ variable "app-env-json-b64" {
variable "memory-limit" {
type = number
description = "Memory limit in bytes"
default = 32 * 1024 * 1024
default = 64 * 1024 * 1024
}

3 changes: 2 additions & 1 deletion internal/sms-gateway/repositories/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type MessagesRepository struct {
func (r *MessagesRepository) SelectPending(deviceID string) (messages []models.Message, err error) {
err = r.db.
Where("device_id = ? AND state = ?", deviceID, models.ProcessingStatePending).
Order("id").
Order("id DESC").
Limit(100).
Preload("Recipients").
Find(&messages).
Error
Expand Down

0 comments on commit 3a2cd96

Please sign in to comment.