[ 
https://issues.apache.org/jira/browse/SLING-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887723#action_12887723
 ] 

Bertrand Delacretaz commented on SLING-550:
-------------------------------------------

Starting work on this now (it's been only two years ;-), committed a first shot 
in revision 963686.

Here's an example with the supplied test servlet, using the sling:bg parameter 
to run it in the background:

$ curl -s "http://localhost:8888/system/bgservlets/test?sling:bg"; | grep "in 
the background" | head -1

<title>202 Running request in the background using Background request job: 
org.apache.sling.bgservlets.impl.ServletResponseWrapper:/var/folders/Ao/AoRgBYXQEPCEzwtY3VTbPE+++TI/-Tmp-/ServletResponseWrapper611074873126683939.data</title>

$ tail -f 
/var/folders/Ao/AoRgBYXQEPCEzwtY3VTbPE+++TI/-Tmp-/ServletResponseWrapper611074873126683939.data

Cycle 5 of 10
Flushing output
Cycle 6 of 10
Cycle 7 of 10
Flushing output
Cycle 8 of 10
Cycle 9 of 10
Flushing output
Cycle 10 of 10
All done.

The test servlet runs in the background and its output is written to a 
temporary file.

Next steps are to implement job control, to suspend/resume/stop/restart such 
jobs, using a simple Felix console plugin as the UI.

> nohup-like service for long-running scripts or servlets
> -------------------------------------------------------
>
>                 Key: SLING-550
>                 URL: https://issues.apache.org/jira/browse/SLING-550
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Bertrand Delacretaz
>            Priority: Minor
>
> In some cases (like the webloader example), long-running processes need to be 
> started, monitored and stopped.
> The webloader implements this in a naive way, it might be useful to have a 
> more generic facility for this: a service that would:
> 1) Start a script or servlet, probably passing it a fake request object that 
> gives access to parameters and output but is not a real HTTP request
> 2) Display a status page where currently running jobs can be monitored, and 
> stopped if desired
> 3) Collect the output of such jobs in the repository and give access to it 
> via a simple monitoring interface
> The output of long-running jobs could be structured using html conventions 
> (like <div class="status">running step 3 of 12</div>) to create overview 
> displays of all currently running jobs.
> This is just an idea for now, I'm not going to work on this right away, but 
> it's probably good to keep in our wishlist.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to