Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default path of Celery beat service?

Tags:

python

celery

I installed Celery as a Windows service. My code moves *.pid and Celery log files into another directory, but three files (celerybeat-schedule.bak, celerybeat-schedule.dir, celerybeat-schedule.dat) which I am not able to move.

I used below code for changing other file's default path:

command = '"{celery_path}" -A {proj_dir} beat -f "{log_path}" -l info --pidfile="{pid_path}" '.format(
celery_path=os.path.join(PYTHONSCRIPTPATH, 'celery.exe'),
proj_dir=PROJECTDIR,
# log_path_1=os.path.join(INSTDIR,'celery_2.log')),
log_path=os.path.join(tmpdir,'celery_'+cur_date_time+'.log'),
pid_path = os.path.join(tmpdir,'celerybeat_'+cur_date_time+'.pid'))

How to change default path of Celery beat service?

like image 638
Moon Avatar asked Sep 24 '19 05:09

Moon


2 Answers

If you executed celery -A your.project.app beat --help it would print you very useful CLI help where you would find the solution to your problem - the -s <path to the scheduler database file> flag.

-s SCHEDULE, --schedule SCHEDULE
                      Path to the schedule database. Defaults to celerybeat-
                      schedule. The extension '.db' may be appended to the
                      filename. Default is celerybeat-schedule.

All you have to do is to pass a full path to the schedule database file to your Celery beat process. Example: -s C:/services/celery/celerybeat-schedule.db

like image 115
DejanLekic Avatar answered Nov 06 '22 03:11

DejanLekic


Finally I am able to change path of celery services using below code.

command = '"{celery_path}" -A {proj_dir} beat -f "{log_path}" -l info --pidfile="{pid_path}" '.format(
            celery_path=os.path.join(PYTHONSCRIPTPATH, 'celery.exe'),
            proj_dir=PROJECTDIR,
            # log_path_1=os.path.join(INSTDIR,'celery_2.log')),
            log_path=os.path.join(CELERYDIR,'celery_'+cur_date_time+'.log'),
            # bak_path=os.path.join(CELERYDIR,'celerybeat-schedule'),
            pid_path = os.path.join(CELERYDIR,'celerybeat_'+cur_date_time+'.pid'))
like image 37
Moon Avatar answered Nov 06 '22 04:11

Moon