mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 08:43:37 +00:00
Initial commit
This commit is contained in:
40
apps/worker/project.json
Normal file
40
apps/worker/project.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "worker",
|
||||
"root": "apps/worker",
|
||||
"sourceRoot": "apps/worker",
|
||||
"projectType": "application",
|
||||
"implicitDependencies": ["alveslib"],
|
||||
"targets": {
|
||||
"dev": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "apps/worker",
|
||||
"command": "celery -A worker:app worker --loglevel=info"
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "python3.12 -m compileall apps/worker"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": ".venv/bin/ruff check apps/worker"
|
||||
}
|
||||
},
|
||||
"typecheck": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": ".venv/bin/mypy apps/worker"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": ".venv/bin/pytest apps/worker -v"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
apps/worker/worker.py
Normal file
23
apps/worker/worker.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
import time
|
||||
from celery import Celery
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# Redis connection
|
||||
redis_url = os.getenv("REDIS_URL", "redis://localhost:6379")
|
||||
app = Celery('worker', broker=redis_url, backend=redis_url)
|
||||
|
||||
@app.task
|
||||
def simple_task(message):
|
||||
"""A simple task that processes a message and returns a result"""
|
||||
time.sleep(2) # Simulate some work
|
||||
return f"Processed: {message}"
|
||||
|
||||
@app.task
|
||||
def add_numbers(x, y):
|
||||
"""Simple math task"""
|
||||
return x + y
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.start()
|
||||
Reference in New Issue
Block a user