hosting
OVH
CleverCloud
Danger
Avoid (for production). Too many maintenance re-deployements failed.
ssh
CC still uses master
as main branch. Pushes might be:
git push <remote> main:master
ENV variables
Background application
By default apps are web focused, with middleware options such as daphne, gunicorn, uvicorn or uwsgi.
To run a script without being web focused, it is possible as a 'worker':
main.py
def application(env, start_response):
start_response("200 OK", [])
return [b"uwsgi application running"]
task.py
import time
from apscheduler.schedulers.background import BackgroundScheduler
def hello():
# important to flush to get it printed outside worker
print("Hello world!", flush=True)
print("Starting scheduler...")
scheduler = BackgroundScheduler()
scheduler.add_job(hello, 'interval', seconds=5, id='job1', replace_existing=True)
scheduler.start()
print("Scheduler started...")
while True:
time.sleep(0.01)
Define env variables as:
Variable | Value |
---|---|
CC_PYTHON_MODULE | main |
CC_WORKER_COMMAND | python3 task.py |