I have a web application managed by an emperor and two distinct vassals. Because they both write to different data sources, I need a file to synchronise both and so I've decided to add a timer job to my emperor.ini:
[uwsgi]
strict = True
die-on-term = True
memory-report = True
uid = www-data
gid = www-data
emperor = xxx.ini
logdate = True
import = synchronize
And this is synchronize.py
:
from uwsgidecorators import rbtimer, lock
INTERVAL = 10
@lock
@rbtimer(INTERVAL)
def synchronize():
""" Synchronizes data between Redis and PostgreSQL. """
print 'AAA'
I run my emperor thus: uwsgi --ini emperor.ini
but nothing happens, the console never prints 'AAA'.
What else am I missing?
You need a process (a worker or a mule) to run the signal handler. Spawn a worker (adding a socket directive) or a mule (adding mule = true). In the case of a mule you need to add target=mule to the @rbtimer decorator)