Re: clsql hunchentoot problem working together



On Dec 30, 7:08 pm, lisp linux <gmail....@xxxxxxxxxx> wrote:
Hi

I am having trouble figuring out where my problem is.
I have already spent more than a day trying to solve it myself.
(In this post 'server' refers to hunchentoot)

You are making a few common newb mistakes.. you seem to be a little
confused as to which 'time' things happen at.

Each of the following cases were put in a lisp file,
loaded using C-c C-k  .
Between each test run, I deleted all generated fasl and "*.so" files
and restarted emacs and slime (and hence sbcl).
This is on linux ( FC8 ) sbcl  1.0.10

Please please help either reproducing or solving
--------------------------------------------------------------
;Following works and starts the server
(eval-when (:compile-toplevel :load-toplevel :execute)
;(asdf:operate 'asdf:load-op 'clsql)
  (asdf:operate 'asdf:load-op 'hunchentoot))

(defpackage :clsqlhunch)
(cl:in-package :clsqlhunch)

(cl:defvar *server* (hunchentoot:start-server :port 7777))

Good .. that should work indeed. On thing i'd suggest is :USE'ing the
common lisp pacakge. Also, it's generally a terrible idea to include
the package definition and the in-package form in the same file. You
run the risk of errors and conficts that are best avoided. Usually a
'packages.lisp' or similar is used to store the pacakge definition
source.


----------------------------------------------------
;Following compiles loads and gets to the repl prompt
;but the server does not seem to be up
(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:operate 'asdf:load-op 'clsql)
  (asdf:operate 'asdf:load-op 'hunchentoot))

(defpackage :clsqlhunch)
(cl:in-package :clsqlhunch)

(cl:defvar *server* (hunchentoot:start-server :port 7777))

How are you testing if the server is 'up'? What is the value of
*SERVER* at this point? Are you aware of the difference between DEFVAR
and DEFPARAMETER?

----------------------------------------------
;following gives the error
;-- SB-INT:SIMPLE-READER-PACKAGE-ERROR at 179 (line 8, column 45) on #<SB-SYS:FD-STREAM for "file
;/home/antony/temp/problem.lisp" {1005CAD601}>:
;       package "HUNCHENTOOT" not found
(asdf:operate 'asdf:load-op 'clsql)
(asdf:operate 'asdf:load-op 'hunchentoot)

(defpackage :clsqlhunch)
(cl:in-package :clsqlhunch)

(cl:defvar *server* (hunchentoot:start-server :port 7777))

Ayuh, as well it should. In common lisp, certain things happen at
certain times. I won't get into too much detail, because interning
these ideas are paramount to understanding CL and learning on your own
will be so much more productive, but it should suffice to say that
your cl:defvar form is being READ before the hunchentoot package is
defined. Your EVAL-WHEN in the previous file shows that you seem to
know some of this... perhaps you were just cargo-culting.

In any case, the clhs section on compilation is a great read.

------------------------------------------------
;following gets me to repl prompt

(asdf:operate 'asdf:load-op 'clsql)
(asdf:operate 'asdf:load-op 'hunchentoot)

(defpackage :clsqlhunch)
(cl:in-package :clsqlhunch)

;(cl:defvar *server* (hunchentoot:start-server :port 7777))

;at the repl typing
(cl:in-package :clsqlhunch)
(cl:defvar *server* (hunchentoot:start-server :port 7777))
;start server ok
---------------------------------------------------------

Ok ... probably an issue of what happens when again. First thing i can
suggest is to _never_ have an 'ASDF:OOS' form in a source file that is
to be compiled and loaded... use ASDF for it's intended purpose,
define a system that :DEPENDS-ON those two systems., and load that
system.

If you _must_ have an OOS in a source file, you'd better know what you
are doing ,and make sure it's evaluated before trying to use something
created via its side effects. EVAL-WHEN and #. are among your friends
here... though i must stress that here be dragons.


Basically the problem seems to be -
"I can't figure out what incantation is needed to have the start server code within a lisp file when
both clsql and hunchentoot are 'require'd "

Nope, that's not really your issue ;). You are misusing ASDF and lack
knowlege of the cl compilation process.


The actual code tries to use asdf, but I'd like understand the basics behind why I *can* start the
http server reliably on repl, but not by loading a lisp file even though it does seem to do that
just fine when clsql is not loaded.

At the REPL you are simply EVAL'ing the forms (that is to say, READ,
EVAL and PRINT in a LOOP). When you compile/load a file, you are
READing, COMPILING, and LOAD'ing before the forms are fully ready to
be evaluated.

If you try to READ a symbol into a package before that package exists,
you'll get an error. Reading the CLHS can clear up these issues, and
teach you quite a bit more as well! :)

FWIW I am a CL newbee.

So, it seems, are the majority of the responsders to your post... The
blind leading the blind as it were. Hopefully i've set you an the
right track in spite of my myopism :)

Cheers ,

drewc
-Antony

.



Relevant Pages

  • Re: fatal error CS0007: Unexpected common language runtime initialization error -- The specified mod
    ... > The strange piece seems to be that it references a non-existant DLL ... > and does not exist on the server anywhere. ... > tempted to reinstall IIS. ... An error occurred during the compilation of a resource ...
    (microsoft.public.dotnet.csharp.general)
  • RE: Trouble with huge amount of State Server Sessions Timed out
    ... As for your question regarding the server the application is hosted of a 2 ... > memory leak, we can first try checking some common things which may cause ... > version app the the server, we haven't changed the "compilation" element's ... Trouble with huge amount of State Server Sessions Timed out ...
    (microsoft.public.dotnet.framework.aspnet)
  • Remote Compilation
    ... We would like to know how you use remote compilation. ... IDE copies files through FTP to server. ...
    (comp.lang.cobol)
  • Re: Can I change my code depending on the build type?
    ... The setting in web.config is only used if the web server does the compilation. ... The release version puts data in a buffer and saves them when the buffer is full or has lived a certain time, but the debug version flushes the buffer for each record so that they show up in the database immediately. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Deploying as CGI
    ... What privileges will I need (on a *nix-style server) to accomplish ... CGI are relatively antinomic to REPL. ... less complex configuration would be using mod_lisp in the web server ...
    (comp.lang.lisp)