Add option to run cron once

issue9475
review307931002
This commit is contained in:
Cédric Krier
2020-07-25 08:03:02 +02:00
parent 15671394ed
commit 9202f337e3
5 changed files with 15 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add option to run cron once
* Add defaults option to route
* Add escape_wildcard in tools
* Add option to ensure emails are sent
+1 -1
View File
@@ -12,7 +12,7 @@ if os.path.isdir(DIR):
import trytond.commandline as commandline
from trytond.config import config
parser = commandline.get_parser_daemon()
parser = commandline.get_parser_cron()
options = parser.parse_args()
config.update_etc(options.configfile)
commandline.config_log(options)
+2
View File
@@ -54,6 +54,8 @@ run the cron server with this command line::
The server will wake up every minutes and preform the scheduled actions defined
in the `database`.
You can also launch the command every few minutes from a scheduler with the
option `--once`.
Worker service
==============
+7
View File
@@ -60,6 +60,13 @@ def get_parser_worker():
return parser
def get_parser_cron():
parser = get_parser_daemon()
parser.add_argument("-1", "--once", dest='once', action='store_true',
help="run pending tasks and halt")
return parser
def get_parser_admin():
parser = get_parser()
+4
View File
@@ -35,4 +35,8 @@ def run(options):
logger.info('start thread for "%s"', db_name)
thread.start()
threads[db_name] = thread
if options.once:
break
time.sleep(60)
for thread in threads.values():
thread.join()