Note that there are some explanatory texts on larger screens.

plurals
  1. PORun R/Rook as a web server on startup
    primarykey
    data
    text
    <p>I have created a server using Rook in R - <a href="http://cran.r-project.org/web/packages/Rook">http://cran.r-project.org/web/packages/Rook</a> Code is as follows</p> <pre><code>#!/usr/bin/Rscript library(Rook) s &lt;- Rhttpd$new() s$add( name="pingpong", app=Rook::URLMap$new( '/ping' = function(env){ req &lt;- Rook::Request$new(env) res &lt;- Rook::Response$new() res$write(sprintf('&lt;h1&gt;&lt;a href="%s"&gt;Pong&lt;/a&gt;&lt;/h1&gt;',req$to_url("/pong"))) res$finish() }, '/pong' = function(env){ req &lt;- Rook::Request$new(env) res &lt;- Rook::Response$new() res$write(sprintf('&lt;h1&gt;&lt;a href="%s"&gt;Ping&lt;/a&gt;&lt;/h1&gt;',req$to_url("/ping"))) res$finish() }, '/?' = function(env){ req &lt;- Rook::Request$new(env) res &lt;- Rook::Response$new() res$redirect(req$to_url('/pong')) res$finish() } ) ) ## Not run: s$start(port=9000) $ ./Rook.r Loading required package: tools Loading required package: methods Loading required package: brew starting httpd help server ... done Server started on host 127.0.0.1 and port 9000 . App urls are: http://127.0.0.1:9000/custom/pingpong Server started on 127.0.0.1:9000 [1] pingpong http://127.0.0.1:9000/custom/pingpong Call browse() with an index number or name to run an application. $ </code></pre> <p>And the process ends here.</p> <p>Its running fine in the R shell but then i want to run it as a server on system startup. So once the start is called , R should not exit but wait for requests on the port. How will i convince R to simply wait or sleep rather than exiting ? I can use the wait or sleep function in R to wait some N seconds , but that doesnt fit the bill perfectly </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload