fix(tasks): 🐛 Flush not working.

This commit is contained in:
Nyeki.py
2024-11-05 00:47:13 -03:00
parent 9fef2c089b
commit 8af01ae327
9 changed files with 94 additions and 96 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"conventionalCommits.scopes": ["bot", "db"], "conventionalCommits.scopes": ["bot", "db", "tasks"],
"yaml.schemas": { "yaml.schemas": {
"kubernetes://schema/apps/v1%40deployment": "file:///c%3A/Users/rafab/Documents/Repos/Payphone-1/k8s.yml" "kubernetes://schema/apps/v1%40deployment": "file:///c%3A/Users/rafab/Documents/Repos/Payphone-1/k8s.yml"
} }
+47 -40
View File
@@ -12,46 +12,53 @@ spec:
targetPort: 5432 targetPort: 5432
--- ---
apiVersion: apps/v1 apiVersion: v1
kind: StatefulSet 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: metadata:
name: postgresql name: postgresql
labels:
app: postgresql
spec: spec:
serviceName: postgresql containers:
replicas: 1 # Single-node PostgreSQL - name: postgres
selector: image: postgres:latest # Standard PostgreSQL image
matchLabels: args:
app: postgresql - -c
template: - max_connections=2000
metadata: env:
labels: - name: POSTGRES_DB
app: postgresql value: "payphone"
spec: - name: POSTGRES_USER
containers: value: "payphone"
- name: postgres - name: POSTGRES_PASSWORD
image: postgres:latest # Standard PostgreSQL image value: "payphone"
args: ports:
- -c - containerPort: 5432
- max_connections=2000 volumeMounts:
env: - name: postgres-storage
- name: POSTGRES_DB mountPath: /var/lib/postgresql/data
value: "payphone" resources:
- name: POSTGRES_USER requests:
value: "payphone" cpu: "1.5"
- name: POSTGRES_PASSWORD memory: "3Gi"
value: "payphone" limits:
ports: cpu: "2"
- containerPort: 5432 memory: "4Gi"
volumeMounts: volumes:
- name: postgres-storage - name: postgres-storage
mountPath: /var/lib/postgresql/data persistentVolumeClaim:
subPath: postgres claimName: postgres-storage
volumeClaimTemplates: restartPolicy: Always
- metadata:
name: postgres-storage
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: openebs-hostpath # Your storage class
resources:
requests:
storage: 20Gi # Adjust storage as needed
+39 -48
View File
@@ -1,51 +1,42 @@
apiVersion: apps/v1 apiVersion: v1
kind: Deployment kind: Pod
metadata: metadata:
name: tasks name: tasks
spec: spec:
replicas: 1 containers:
selector: - name: flush
matchLabels: image: git.nyeki.dev/payphone/payphone-tasks:latest
app: tasks command: ["uv", "run", "--no-dev", "tasks.py", "flush"]
template: resources:
metadata: requests:
labels: memory: "250Mi"
app: tasks cpu: "100m"
spec: limits:
containers: memory: "1Gi"
- name: flush cpu: "1"
image: git.nyeki.dev/payphone/payphone-tasks:latest - name: delete-accounts
command: ["uv", "run", "--no-dev", "tasks.py", "flush"] image: git.nyeki.dev/payphone/payphone-tasks:latest
resources: command: ["uv", "run", "--no-dev", "tasks.py", "delete-accounts"]
requests: resources:
memory: "250Mi" requests:
cpu: "100m" memory: "250Mi"
limits: cpu: "100m"
memory: "1Gi" limits:
cpu: "1" memory: "1Gi"
- name: delete-accounts cpu: "1"
image: git.nyeki.dev/payphone/payphone-tasks:latest - name: hangup-inactive-calls
command: ["uv", "run", "--no-dev", "tasks.py", "delete-accounts"] image: git.nyeki.dev/payphone/payphone-tasks:latest
resources: command: ["uv", "run", "--no-dev", "tasks.py", "hangup-inactive-calls"]
requests: envFrom:
memory: "250Mi" - secretRef:
cpu: "100m" name: bot-secrets
limits: resources:
memory: "1Gi" requests:
cpu: "1" memory: "250Mi"
- name: hangup-inactive-calls cpu: "100m"
image: git.nyeki.dev/payphone/payphone-tasks:latest limits:
command: ["uv", "run", "--no-dev", "tasks.py", "hangup-inactive-calls"] memory: "1Gi"
envFrom: cpu: "1"
- secretRef: restartPolicy: Always
name: bot-secrets imagePullSecrets:
resources: - name: regcred
requests:
memory: "250Mi"
cpu: "100m"
limits:
memory: "1Gi"
cpu: "1"
restartPolicy: Always
imagePullSecrets:
- name: regcred
-1
View File
@@ -47,7 +47,6 @@ class Payphone(commands.AutoShardedBot):
help_command=help_command.HelpCommand(), help_command=help_command.HelpCommand(),
strip_after_prefix=True, strip_after_prefix=True,
case_insensitive=True, case_insensitive=True,
owner_ids=[898569996949676052, 777338793803513886],
) )
async def on_ready(self) -> None: async def on_ready(self) -> None:
+1 -1
View File
@@ -15,7 +15,7 @@ async def flush():
from payphone.core import constants, utils, config 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() pipe = redis.pipeline()
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "payphone" name = "payphone"
version = "0.14.0" version = "0.15.0"
description = "Add your description here" description = "Add your description here"
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
+2 -2
View File
@@ -264,7 +264,7 @@ class RunnableHashMixin:
return self.command("HGETALL", str(key)) 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. """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 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: Args:
key (str): The key of the hash whose field to increment. key (str): The key of the hash whose field to increment.
field (str): The 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: Returns:
int: The amount returned int: The amount returned
+2 -1
View File
@@ -1,5 +1,6 @@
import os import os
import sys import sys
import getpass
try: try:
import requests import requests
@@ -12,7 +13,7 @@ except ImportError:
sys.exit() sys.exit()
username = input("Username for git.nyeki.dev: ") 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( tags = requests.get(
"https://git.nyeki.dev/v2/payphone/payphone-shard/tags/list", "https://git.nyeki.dev/v2/payphone/payphone-shard/tags/list",
Generated
+1 -1
View File
@@ -411,7 +411,7 @@ wheels = [
[[package]] [[package]]
name = "payphone" name = "payphone"
version = "0.13.0" version = "0.14.0"
source = { virtual = "." } source = { virtual = "." }
dependencies = [ dependencies = [
{ name = "aerich" }, { name = "aerich" },