The ScriptTask provides a way for code to be run at the commandline via paster script ... and also as a task, e.g. enqueued via the web /nf/admin/task_manager/new
But paster commands can only be run via the commandline right now. We'd like a something similar to ScriptTask for paster commands. Use ReindexCommand as your example and convert it so it can be run exactly as-is via paster, but also as a task. I don't know exactly what the architecture should be, but some ideas: add __new__, __metaclass__ etc to command.base.Command so that all commands get it (not necessary, could be a mixin class). May be useful for this to share code directly with ScriptTask somehow.
Created #334: [#6191] make paster commands runnable as background tasks (4cp)
Related
Tickets:
#6191Closed #334.
je/42cc_6191It uses
run_commandtask to run the command from taskd (takes actual command as argument). Approach with__new__, like inScriptTaskbreaks command behavior when running from commandline, so I've stick with that.I run it as follows (from /nf/admin/task_manager/new):
task name:
args:
{ "args": ["/var/local/config/production.ini -p project3"], "kwargs": {} }Note that you need to provide ini-file in arguments, this is not very convenient, but paster command needs it, and I'm unable to figure out how to bypass it.
Actually, on a sandbox, relative paths worked for me too, e.g.
"args": ["production.ini -p project3"],While this does work well, I'd like some changes so that the task_name is
allura.command.show_models.ReindexCommandrather than all paster command/tasks using the genericallura.command.base.run_commandtask_name. For comparison, that's why the__new__was used in ScriptTask.Oh, just re-read your comments about why
__new__doesn't work.