Page 1 of 1

Installing Dragonfly to hosted server

Posted: Thu Jun 24, 2010 9:28 pm
by 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.

Code: Select all

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.

Re: Installing Dragonfly to hosted server

Posted: Fri Jun 25, 2010 12:31 am
by itistoday
Check your DRAGONFLY_ROOT constant, make sure it's correctly set. In the standard config.lsp it's set to this:

Code: Select all

; 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.

Re: Installing Dragonfly to hosted server

Posted: Fri Jun 25, 2010 6:17 pm
by Ryon
I replaced (env "DOCUMENT_ROOT") with a fully qualified path:

Code: Select all

; 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:

Code: Select all

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.
.

Re: Installing Dragonfly to hosted server

Posted: Fri Jun 25, 2010 6:53 pm
by itistoday
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.

Re: Installing Dragonfly to hosted server

Posted: Sat Jun 26, 2010 3:57 pm
by cormullion
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:

Code: Select all

(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:

Code: Select all

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...

Re: Installing Dragonfly to hosted server

Posted: Tue Jun 29, 2010 12:46 am
by Ryon
You're right, it's not easy! But I haven't given up. I've run into a problem at

Code: Select all

    (true
        (if (args) (set farg (eval (first (args)))) (set farg nil)))
    ) 
of your code, Cormullion. I get

Code: Select all

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

Code: Select all

(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.

Re: Installing Dragonfly to hosted server

Posted: Sun Jul 11, 2010 12:08 pm
by hilti
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

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

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

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

Code: Select all

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

Re: Installing Dragonfly to hosted server

Posted: Tue Jul 13, 2010 12:38 am
by Ryon
No luck quite yet.

Standard configuration 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!