Installing Dragonfly to hosted server

Started by Ryon, June 24, 2010, 02:28:36 PM

Previous topic - Next topic

Ryon

I'm having trouble installing the Dragonfly framework to my hosted account. I copied the dragonfly-framework folder, index.cgi, and .htaccess to my site's root folder per the installation instructions. It appears that I do not need to make any changes to the config.lsp file. And I changed the hashbang line to point to a known-good newlisp-10.2.8.


ERR: problem accessing file : "/home/myacct/webapps/_/dragonfly-framework/lib/utils.lsp"
I suppose '_' above represents my web root directory. The utils.lsp is in the above path.
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"

itistoday

#1
Check your DRAGONFLY_ROOT constant, make sure it's correctly set. In the standard config.lsp it's set to this:


; docroot (also site root, usually doesn't need modification)
(constant (global 'DOCUMENT_ROOT) (env "DOCUMENT_ROOT"))
; dragonfly root
(constant (global 'DRAGONFLY_ROOT) (string DOCUMENT_ROOT "/dragonfly-framework"))


So you see it's based on DOCUMENT_ROOT being set properly in the environment. It normally is if you're using apache or the newlisp server.
Get your Objective newLISP groove on.

Ryon

#2
I replaced (env "DOCUMENT_ROOT") with a fully qualified path:
; docroot (also site root, usually doesn't need modification)
; (constant (global 'DOCUMENT_ROOT) (env "DOCUMENT_ROOT"))
(constant (global 'DOCUMENT_ROOT) "/home/myacct/webapps/myapp")

The welcome page now shows, but the URLs are now:


http://www.mysite.com/ysiteapp/welcome
etc., which brings up a proper 404 error page (Hey, something went right!). But note the missing 'm' in the fictional '/mysiteapp' directory.

.
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"

itistoday

#3
I'd have to look at your setup to be able to figure out what's going wrong, I can't just guess.



To figure this out, the files you need to look at are config.lsp and dragonfly.lsp.
Get your Objective newLISP groove on.

cormullion

#4
It's difficult to troubleshoot these things.  Since using the debugger is not possible, you can try things like logging and printing debug information. Dragonfly has a set of built-in log functions.



Since this is (new)LISP, another thing you can try is to arrange for all functions to be redefined so that they generate a log when they're called. For example, add code like this near the beginning of index.cgi:


(context 'tracer)
(define-macro (tracer:tracer farg)
    (cond
     ((list? farg)
        (set (farg 0)
            (letex (func   (farg 0)
                    arg    (rest farg)
                    arg-p  (cons 'list
                                (map (fn (x)
                                    (if (list? x) (first x) x))
                                (rest farg)))
                    body   (cons 'begin (args)))
                   (lambda
                       arg
                       (append-file
                         "/tmp/trace.log"
                         (string (date) { } (context) {:} 'func { } arg-p "n"))
                       body))))                  
     (true
        (if (args) (set farg (eval (first (args)))) (set farg nil)))
    )  
)


and you'll get a record of what happened:


Sat Jun 26 15:47:39 2010 MAIN:load-files-in-dir ("/home/public/dragonfly-framework/lib" ".lsp$")
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 Response:content-type ("text/html; charset=utf-8")
Sat Jun 26 15:47:39 2010 Response:header ("Content-Type")
Sat Jun 26 15:47:39 2010 Response:header ("Connection")
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 Request:parse-query ("welcome")
Sat Jun 26 15:47:39 2010 Request:utf8-urldecode ("welcome")
Sat Jun 26 15:47:39 2010 Request:utf8-urldecode ("")
Sat Jun 26 15:47:39 2010 Request:add-keyvalue-to-ctx ("welcome" "" $GET)
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:run ()
Sat Jun 26 15:47:39 2010 Dragonfly:listener ()
Sat Jun 26 15:47:39 2010 MAIN:load-files-in-dir ("/home/public/dragonfly-framework/plugins-active" ".lsp$")
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()
Sat Jun 26 15:47:39 2010 MAIN:load-once ()


I wouldn't claim it's perfect (Dragonfly/newLISP is pretty complex in my view) , but it can help you get a feel for what's happening when...

Ryon

#5
You're right, it's not easy! But I haven't given up. I've run into a problem at
   (true
        (if (args) (set farg (eval (first (args)))) (set farg nil)))
    )
of your code, Cormullion. I get ERR: symbol expected in function set : farg
called from user defined function tracer:tracer
unless it is commented out.



I did do a simple-minded
(append-file "/home/myhome/webapps/myapp/dragonfly-framework/test.tmp" DOCUMENT_ROOT)
for DOCUMENT_ROOT, DRAGONFLY_ROOT, VIEWS_PATH, and PARTIALS_PATH and they all hold the correct paths.



I'm running low on psychic energy for the moment, so the mystery of the missing character in the path is still unsolved. I wonder if it could be something external to the program. I find that Nginx handles the frontend proxy requests on their server, whatever the heck that means.
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"

hilti

#6
Hi Ryon,



the Nginx webserver uses different rewrite rules. Maybe that's the problem.

Try to install the Dragonfly example site and access it this way:



http://www.rundragonfly.com/index.cgi/dragonfly_routes">//http://www.rundragonfly.com/index.cgi/dragonfly_routes



HOW TO convert an Apache htaccess to Nginx rewrite rules? Try this link:



http://www.anilcetin.com/convert-apache-htaccess-to-nginx/">//http://www.anilcetin.com/convert-apache-htaccess-to-nginx/



After converting the Dragonfly .htaccess file You'll get this:



if (!-d $request_filename){
set $rule_0 1$rule_0;
}
if ($request_filename !~ "-l"){
set $rule_0 2$rule_0;
}
#ignored: condition 2
if ($request_filename ~ ".(html|nl)$"){
set $rule_0 4$rule_0;
}
if ($rule_0 = "431"){
rewrite /(.*) /index.cgi?$1 last;
}


Hope this helps!



Cheers

Hilti
--()o Dragonfly web framework for newLISP

http://dragonfly.apptruck.de\">http://dragonfly.apptruck.de

Ryon

#7
No luck quite yet.



Standard configuration http://www.myapp.com/index.cgi/dragonfly_routes">http://www.myapp.com/index.cgi/dragonfly_routes returns:



ERR: problem accessing file : "/home/me/webapps/_/dragonfly-framework/lib/utils.lsp"



Note the web root directory is found as a '_'. There is no server error log entry.



Changing the global 'DOCUMENT_ROOT in config.lsp to "/home/me/webapps/myapp" it serves the 404 page:



Not Found. The requested URL yapp/ resulted in error 404 Not Found.



Note the letter 'm' is missing from myapp/. This is consistent with the rest of the errors; the first letter of the web root directory will be truncated. Still no server error log entry.



Trying .htaccess converted to Nginx rules results in Internal Server Error being served. The log shows:



[Mon Jul 12 19:23:33 2010] [alert] [client 12.345.67.89] /home/me/webapps/myapp/.htaccess: Invalid command 'if', perhaps misspelled or defined by a module not included in the server configuration



I'm trying to learn more about the host configuration. It appears the files are served by Apache, with Nginx in front, and I don't understand exactly what this means. I do think the problem is outside of Dragonfly itself.



Thanks for the help!
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"