diff --git a/.vscode/settings.json b/.vscode/settings.json index fee4936..6094f00 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "conventionalCommits.scopes": ["bot", "db"], + "conventionalCommits.scopes": ["bot", "db", "tasks"], "yaml.schemas": { "kubernetes://schema/apps/v1%40deployment": "file:///c%3A/Users/rafab/Documents/Repos/Payphone-1/k8s.yml" } diff --git a/k8s/psql.yml b/k8s/psql.yml index 0b7280a..7251720 100644 --- a/k8s/psql.yml +++ b/k8s/psql.yml @@ -12,46 +12,53 @@ spec: targetPort: 5432 --- -apiVersion: apps/v1 -kind: StatefulSet +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: postgres-storage +spec: + accessModes: + - ReadWriteOnce + storageClassName: openebs-hostpath # Your storage class + resources: + requests: + storage: 20Gi # Adjust storage as needed + +--- +apiVersion: v1 +kind: Pod metadata: name: postgresql + labels: + app: postgresql spec: - serviceName: postgresql - replicas: 1 # Single-node PostgreSQL - selector: - matchLabels: - app: postgresql - template: - metadata: - labels: - app: postgresql - spec: - containers: - - name: postgres - image: postgres:latest # Standard PostgreSQL image - args: - - -c - - max_connections=2000 - env: - - name: POSTGRES_DB - value: "payphone" - - name: POSTGRES_USER - value: "payphone" - - name: POSTGRES_PASSWORD - value: "payphone" - ports: - - containerPort: 5432 - volumeMounts: - - name: postgres-storage - mountPath: /var/lib/postgresql/data - subPath: postgres - volumeClaimTemplates: - - metadata: - name: postgres-storage - spec: - accessModes: [ "ReadWriteOnce" ] - storageClassName: openebs-hostpath # Your storage class - resources: - requests: - storage: 20Gi # Adjust storage as needed + containers: + - name: postgres + image: postgres:latest # Standard PostgreSQL image + args: + - -c + - max_connections=2000 + env: + - name: POSTGRES_DB + value: "payphone" + - name: POSTGRES_USER + value: "payphone" + - name: POSTGRES_PASSWORD + value: "payphone" + ports: + - containerPort: 5432 + volumeMounts: + - name: postgres-storage + mountPath: /var/lib/postgresql/data + resources: + requests: + cpu: "1.5" + memory: "3Gi" + limits: + cpu: "2" + memory: "4Gi" + volumes: + - name: postgres-storage + persistentVolumeClaim: + claimName: postgres-storage + restartPolicy: Always diff --git a/k8s/tasks.yml b/k8s/tasks.yml index 063d717..fd106ce 100644 --- a/k8s/tasks.yml +++ b/k8s/tasks.yml @@ -1,51 +1,42 @@ -apiVersion: apps/v1 -kind: Deployment +apiVersion: v1 +kind: Pod metadata: name: tasks spec: - replicas: 1 - selector: - matchLabels: - app: tasks - template: - metadata: - labels: - app: tasks - spec: - containers: - - name: flush - image: git.nyeki.dev/payphone/payphone-tasks:latest - command: ["uv", "run", "--no-dev", "tasks.py", "flush"] - resources: - requests: - memory: "250Mi" - cpu: "100m" - limits: - memory: "1Gi" - cpu: "1" - - name: delete-accounts - image: git.nyeki.dev/payphone/payphone-tasks:latest - command: ["uv", "run", "--no-dev", "tasks.py", "delete-accounts"] - resources: - requests: - memory: "250Mi" - cpu: "100m" - limits: - memory: "1Gi" - cpu: "1" - - name: hangup-inactive-calls - image: git.nyeki.dev/payphone/payphone-tasks:latest - command: ["uv", "run", "--no-dev", "tasks.py", "hangup-inactive-calls"] - envFrom: - - secretRef: - name: bot-secrets - resources: - requests: - memory: "250Mi" - cpu: "100m" - limits: - memory: "1Gi" - cpu: "1" - restartPolicy: Always - imagePullSecrets: - - name: regcred + containers: + - name: flush + image: git.nyeki.dev/payphone/payphone-tasks:latest + command: ["uv", "run", "--no-dev", "tasks.py", "flush"] + resources: + requests: + memory: "250Mi" + cpu: "100m" + limits: + memory: "1Gi" + cpu: "1" + - name: delete-accounts + image: git.nyeki.dev/payphone/payphone-tasks:latest + command: ["uv", "run", "--no-dev", "tasks.py", "delete-accounts"] + resources: + requests: + memory: "250Mi" + cpu: "100m" + limits: + memory: "1Gi" + cpu: "1" + - name: hangup-inactive-calls + image: git.nyeki.dev/payphone/payphone-tasks:latest + command: ["uv", "run", "--no-dev", "tasks.py", "hangup-inactive-calls"] + envFrom: + - secretRef: + name: bot-secrets + resources: + requests: + memory: "250Mi" + cpu: "100m" + limits: + memory: "1Gi" + cpu: "1" + restartPolicy: Always + imagePullSecrets: + - name: regcred diff --git a/payphone/bot.py b/payphone/bot.py index b58fa0e..b12f4a2 100644 --- a/payphone/bot.py +++ b/payphone/bot.py @@ -47,7 +47,6 @@ class Payphone(commands.AutoShardedBot): help_command=help_command.HelpCommand(), strip_after_prefix=True, case_insensitive=True, - owner_ids=[898569996949676052, 777338793803513886], ) async def on_ready(self) -> None: diff --git a/procs/flush_messages.py b/procs/flush_messages.py index 24b3519..896f59e 100644 --- a/procs/flush_messages.py +++ b/procs/flush_messages.py @@ -15,7 +15,7 @@ async def flush(): from payphone.core import constants, utils, config - redis = redis.Redis("localhost" if config.IS_DEBUG else "redis") + redis = redis.Redis("redis://localhost" if config.IS_DEBUG else "redis://redis") pipe = redis.pipeline() diff --git a/pyproject.toml b/pyproject.toml index fceaeaa..dd06381 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "payphone" -version = "0.14.0" +version = "0.15.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" diff --git a/redis/__init__.py b/redis/__init__.py index 71b755d..e604da3 100644 --- a/redis/__init__.py +++ b/redis/__init__.py @@ -264,7 +264,7 @@ class RunnableHashMixin: return self.command("HGETALL", str(key)) - def hincrby(self, key: str, field: str, increment: int) -> int: + def hincrby(self, key: str, field: str, increment: int = 1) -> int: """Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the @@ -274,7 +274,7 @@ class RunnableHashMixin: Args: key (str): The key of the hash whose field to increment. field (str): The field to increment. - increment (int): The amount to increment by. + increment (int, optional): The amount to increment by. Defaults to 1. Returns: int: The amount returned diff --git a/scripts/deploy.py b/scripts/deploy.py index c8538c8..ec37a3f 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -1,5 +1,6 @@ import os import sys +import getpass try: import requests @@ -12,7 +13,7 @@ except ImportError: sys.exit() username = input("Username for git.nyeki.dev: ") -password = input("Password for git.nyeki.dev: ") +password = getpass.getpass("Password for git.nyeki.dev: ") tags = requests.get( "https://git.nyeki.dev/v2/payphone/payphone-shard/tags/list", diff --git a/uv.lock b/uv.lock index eeb9bdc..44f5853 100644 --- a/uv.lock +++ b/uv.lock @@ -411,7 +411,7 @@ wheels = [ [[package]] name = "payphone" -version = "0.13.0" +version = "0.14.0" source = { virtual = "." } dependencies = [ { name = "aerich" },