Add option to run cron once
issue9475 review307931002
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
@@ -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
|
||||
==============
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user