Re: [racket-users] Racket and FastCGI

2015-04-05 Thread Giuseppe Luca Scrofani
> Looks like you specified reaching the SCGI server via a Unix domain
> socket, but you never told the Racket program to use that socket. You
> actually can't use that kind of socket with the Racket SCGI library --
> typically, the SCGI server will talk TCP to localhost on a specific port.
>
> Offhand, I can't tell you confidently the exact lighttpd configuration to
> use, since the lighttpd SCGI module appears not clearly documented, but you
> can figure it out from:
> http://redmine.lighttpd.net/projects/1/wiki/Docs_ModSCGI
>

Thanks for answer, I will study Lighttpd doc more, but on this subject it
seems to me a little vague.
In the meantime I will use standard CGI. Response time to scripts in
racket/base language are satisfactory for local use. (I wonder if pointing
to compiled scripts will make a noticeable difference, I have to try).
When I will need more performance if I can not find a way with lighttpd I
will try Apache or Nginx.

Please let me explain why I think CGI are a useful approach even if more
advanced tools for web application are already available in Racket:
Consider the opportunity to have a directory in your workstation's home
full of subdirectories with a number of potentially almost independent,
reusable, well documented, simple little scripts. You can use them from
your browser to make almost anything (from managing your system, to your
data, to making graphics programs, to forge code editors...) using all the
power of Racket, and this collection can grow organically over time without
or with little previous planning.
Scripts can be easily made to interact, just like functions. Complex
systems will pop-up in short time. I happily used Lua in the past to do all
this. But Racket can serve me better of an order of magnitude.
Xexpr's obviously are a fantastic option to make all sorts of HTML user
interfaces without touching a line of HTML. CSS can be also
programmatically generated or use statically to alter "GUI" as you like
with great versatility in every development phase.
I personally dislike JS, despite all the time I played with Node... But
used sparingly can be very useful in such a system. Some pre-made ajax
helper functions used well can do wonders.
Forgive me to state the obvious: web-applications are very useful. But, the
need to make enormous preplanned apps, or run a thousand independent Racket
server to achieve what I want is something I can escape with CGI.
Thanks for attention.

Lux

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-04 Thread Neil Van Dyke

Lux wrote on 04/03/2015 05:47 AM:

cgi.assign = ( ".rkt" => "/usr/bin/racket" )

scgi.server = ( ".rkt" => ((
 "bin-path" => "/usr/bin/racket",
 "socket" => "/tmp/racket.socket"
   )))

scgi.debug = 1
--

Trying to get: http://localhost/scgi-test/scgi.rkt
Result in: 500 - Internal Server Error

I think I miss something important here...


Looks like you specified reaching the SCGI server via a Unix domain 
socket, but you never told the Racket program to use that socket. You 
actually can't use that kind of socket with the Racket SCGI library -- 
typically, the SCGI server will talk TCP to localhost on a specific port.


Offhand, I can't tell you confidently the exact lighttpd configuration 
to use, since the lighttpd SCGI module appears not clearly documented, 
but you can figure it out from: 
http://redmine.lighttpd.net/projects/1/wiki/Docs_ModSCGI


Neil V.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-03 Thread Vincent St-Amour
At Fri, 3 Apr 2015 08:14:10 -0700 (PDT),
Lux wrote:
> 
> Thanks for your welcoming words, Vincent.
> 
> For some reasons I was certain Racket github repository was a sort of
> mirror of the real almost secret repository where superheroes are
> working hard to make it real...

The core repo is indeed a mirror of git.racket-lang.org, but a lot of
discussion and development is done on Github via pull requests.

As for superheroes, I'm only aware of Matthew. The rest of us are pretty
ordinary folk. ;)

Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-03 Thread Lux
Thanks for your welcoming words, Vincent.

For some reasons I was certain Racket github repository was a sort of mirror of 
the real almost secret repository where superheroes are working hard to make it 
real... I will join and see if I can adapt.

I've used scribble initially to document my development efforts (so I can use 
it) but in the end I've come up with a custom doc generator due to weird 
particular requirements.

Let me organize one ad-hoc "workspace" on my computer to efficiently work on 
this subjects and I will try.

Lux



> Absolutely! We would welcome additional examples in the docs.
> 
> The Racket docs are written in Scribble [1], and developed on Github.
> The main Racket docs are at:
> 
> https://github.com/plt/racket/tree/master/pkgs/racket-doc/scribblings
> 
> Docs for other packages in the main distribution are typically included
> in the repository for that package. These repositories are available at:
> 
> https://github.com/racket/
> 
> To contribute, all you need to do is update the package you want with
> the --clone option [2], edit the source of the docs, run `raco setup`
> and look at the result. Once you're happy with the result, the only
> thing that's left to do is to submit a pull request to the original
> repository [3].
> 
> Looking forward to your contributions! :)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-03 Thread Vincent St-Amour
At Thu, 2 Apr 2015 20:14:12 -0700 (PDT),
Lux wrote:
> Also, as I use -intensively- Racket docs every day I need to know how
> I can (if it is possible) contribute providing some sample code here
> and here, as I think this is something where it is severely lacking. A
> small snippet showing how to use a feature without implying having
> read half of a module api will be nice, something to hack on as a
> starting base, put it in a file and it work showing an intuitive path
> to follow... I explored almost all library of Racket, the problem
> seems pervasive and I think I can help.

Absolutely! We would welcome additional examples in the docs.

The Racket docs are written in Scribble [1], and developed on Github.
The main Racket docs are at:

https://github.com/plt/racket/tree/master/pkgs/racket-doc/scribblings

Docs for other packages in the main distribution are typically included
in the repository for that package. These repositories are available at:

https://github.com/racket/

To contribute, all you need to do is update the package you want with
the --clone option [2], edit the source of the docs, run `raco setup`
and look at the result. Once you're happy with the result, the only
thing that's left to do is to submit a pull request to the original
repository [3].

Looking forward to your contributions! :)

Vincent



[1] http://docs.racket-lang.org/scribble/index.html
[2] http://docs.racket-lang.org/pkg/cmdline.html#%28part._raco-pkg-update%29
[3] https://help.github.com/articles/using-pull-requests/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-03 Thread Lux
> If you want to use SCGI instead of FastCGI: 
> http://www.neilvandyke.org/racket-scgi/

I am trying with lighttpd. I placed the following example on 
/home/lux/served/scgi-test/scgi.rtk:

--
#lang racket

(require (planet neil/scgi:2:3))
 
(cgi #:startup  (lambda ()
  (printf "Startup for cgi-type ~S..."
  (cgi-type)))
 
 #:request  (lambda ()
  (display "Content-type: text/html\r\n\r\n")
  (display "Hello, world!")
  (printf "Your IP address is: ~S"
  (cgi-remote-addr)))
 
 #:shutdown (lambda ()
  (printf "Shutdown down for cgi-type ~S..."
  (cgi-type
--

I have the following lighttpd configuration (which permit me to use .rkt files, 
excluding your example, as normal CGI):

--
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_cgi",
"mod_scgi",
#   "mod_rewrite",
)

server.document-root= "/home/lux/served"
server.upload-dirs  = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname= "www-data"
server.port = 80

index-file.names= ( "index.rkt", "index.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".rkt" )

compress.cache-dir  = "/var/cache/lighttpd/compress/"
compress.filetype   = ( "application/javascript", "text/css", 
"text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

cgi.assign = ( ".rkt" => "/usr/bin/racket" )

scgi.server = ( ".rkt" => ((
"bin-path" => "/usr/bin/racket",
"socket" => "/tmp/racket.socket"
  )))

scgi.debug = 1
--

Trying to get: http://localhost/scgi-test/scgi.rkt
Result in: 500 - Internal Server Error

I think I miss something important here...

error.log report a long list of line like this:

--
2015-04-03 11:42:50: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-1 1 1 0 
28211 
2015-04-03 11:42:50: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-0 1 1 0 
28208 
2015-04-03 11:42:51: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-3 1 1 0 
28215 
2015-04-03 11:42:51: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-2 1 1 0 
28213 
2015-04-03 11:42:51: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-1 1 1 0 
28211 
2015-04-03 11:42:51: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-0 1 1 0 
28208 
2015-04-03 11:42:52: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-3 1 1 0 
28215 
2015-04-03 11:42:52: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-2 1 1 0 
28213 
2015-04-03 11:42:52: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-1 1 1 0 
28211 
2015-04-03 11:42:52: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-0 1 1 0 
28208 
2015-04-03 11:42:53: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-3 1 1 0 
28215 
2015-04-03 11:42:53: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-2 1 1 0 
28213 
2015-04-03 11:42:53: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-1 1 1 0 
28211 
2015-04-03 11:42:53: (mod_scgi.c.2086) proc:  0 /tmp/racket.socket-0 1 1 0 28208
--

Do you see something?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket and FastCGI

2015-04-02 Thread Neil Van Dyke
If you want to use SCGI instead of FastCGI: 
http://www.neilvandyke.org/racket-scgi/


Neil V.

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Racket and FastCGI

2015-04-02 Thread Lux
Hi. First: Thanks for Racket. I really mean it. You are all fantastic.
Second: How to make it work with FastCGI (and Lighttpd?)?

Doc about net/cgi ( http://docs.racket-lang.org/net/cgi.html ) mention this 
standard and offer some cryptic indication:

""" Users of FastCGI will need to bind REQUEST_METHOD and possibly also 
QUERY_STRING to successfully employ the CGI library. The FastCGI library ought 
to provide a way to extract the values bound to these variables; the user can 
then put these into the CGI program’s environment using the putenv function. """

I can get some more advices?

I already make lighttpd work with .rkt files as simple CGIs.
But obviously this is a slow and inefficient approach.

I worked with servlets, I appreciate them, but I need something much simpler 
and similar to my old style of building web applications. Maybe I am spoiled 
but I see this style as more functional. What is more stateless of a poor 
little ugly CGI script which know only some parameters sent to it via GET or 
POST?

Also, as I use -intensively- Racket docs every day I need to know how I can (if 
it is possible) contribute providing some sample code here and here, as I think 
this is something where it is severely lacking. A small snippet showing how to 
use a feature without implying having read half of a module api will be nice, 
something to hack on as a starting base, put it in a file and it work showing 
an intuitive path to follow... I explored almost all library of Racket, the 
problem seems pervasive and I think I can help.

Sincerely, Lux

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.