#6191 make paster commands runnable as background tasks

v1.0.0
closed
42cc (432)
General
2015-08-20
2013-05-01
No

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.

Related

Tickets: #6191
Tickets: #6192
Tickets: #6239

Discussion

  • Igor Bondarenko - 2013-05-02
    • status: open --> in-progress
     
  • Igor Bondarenko - 2013-05-02

    Created #334: [#6191] make paster commands runnable as background tasks (4cp)

     

    Related

    Tickets: #6191

  • Igor Bondarenko - 2013-05-06
    • status: in-progress --> code-review
     
  • Igor Bondarenko - 2013-05-06

    Closed #334. je/42cc_6191

    It uses run_command task to run the command from taskd (takes actual command as argument). Approach with __new__, like in ScriptTask breaks 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:

    allura.command.show_models.ReindexCommand
    

    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"],

     
  • Dave Brondsema

    Dave Brondsema - 2013-05-09
    • assigned_to: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2013-05-09
    • status: code-review --> in-progress
     
  • Dave Brondsema

    Dave Brondsema - 2013-05-09

    While this does work well, I'd like some changes so that the task_name is allura.command.show_models.ReindexCommand rather than all paster command/tasks using the generic allura.command.base.run_command task_name. For comparison, that's why the __new__ was used in ScriptTask.

     
  • Dave Brondsema

    Dave Brondsema - 2013-05-09

    Oh, just re-read your comments about why __new__ doesn't work.

     
  • Dave Brondsema

    Dave Brondsema - 2013-05-09
    • status: in-progress --> closed
    • assigned_to: Dave Brondsema --> Igor Bondarenko
    • QA: Dave Brondsema
    • Milestone: forge-backlog --> forge-may-17
     

Log in to post a comment.