Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'installer'

  • Loading branch information...
commit 63a04ddf2fe558c84f5a7d67b706b56abb0d209a 2 parents d3efe36 + 0d41f8e
@ursetto authored
View
142 chickadee-cmd.scm
@@ -0,0 +1,142 @@
+;; todo
+;; Check if log is writable. Spiffy will error out (but not until first log attempt).
+
+(use chickadee spiffy uri-common posix)
+(use matchable)
+
+(define args (command-line-arguments))
+(define +basedir+
+ (make-pathname (chicken-home) "chickadee"))
+(define +conf-file+
+ (make-pathname +basedir+ "config.scm"))
+
+(define (usage type)
+ (define (usage-serve)
+ (fprintf (current-error-port)
+ "
+ usage: ~A serve [options] [conf-file]
+
+ Start a chicken-doc web server using the configuration file
+ [conf-file] or the default configuration file,
+ ~A.
+ If provided, [options] override settings in [conf-file].
+
+ options:
+
+ -p --port NUM Port number
+
+ -A --access-log FILE Access log file
+ -E --error-log FILE Error log file
+ -D --debug-log FILE Debug log file
+ -J --ajax-log FILE AJAX access log
+ FILE is a filename relative to the directory holding [conf-file].
+ It may be \"-\" to log to the console or \"\" to suppress logging.
+
+ "
+ (program-name)
+ +conf-file+))
+ (define (usage-help)
+ (fprintf (current-error-port)
+ "chickadee, the chicken-doc server
+
+ usage: ~A command args...
+
+ commands:
+
+ serve Start a chicken-doc webserver
+ location Show location of datafiles
+ help Get help on command
+
+ "
+ (program-name)))
+ (define (usage-location)
+ (fprintf (current-error-port)
+ "
+ usage: ~A location
+
+ Prints information about the location of important chickadee
+ data files, such as the base directory and config file.
+
+ "
+ (program-name)))
+ (cond ((equal? type "serve")
+ (usage-serve))
+ ((equal? type "help")
+ (usage-help))
+ ((equal? type "location")
+ (usage-location))
+ (else (usage "help")))
+ ;(exit 1)
+ )
+
+(match args
+ (("serve" . args)
+ (let collect ((alog #f)
+ (elog #f)
+ (dlog #f)
+ (jlog #f)
+ (port #f)
+ (file +conf-file+)
+ (args args))
+ (cond ((pair? args)
+ (let ((a (car args)))
+ (cond ((or (equal? a "--access-log")
+ (equal? a "-A"))
+ (collect (cadr args) elog dlog jlog port file (cddr args)))
+ ((or (equal? a "--error-log")
+ (equal? a "-E"))
+ (collect alog (cadr args) dlog jlog port file (cddr args)))
+ ((or (equal? a "--debug-log")
+ (equal? a "-D"))
+ (collect alog elog (cadr args) jlog port file (cddr args)))
+ ((or (equal? a "--ajax-log")
+ (equal? a "-J"))
+ (collect alog elog dlog (cadr args) port file (cddr args)))
+ ((or (equal? a "--port")
+ (equal? a "-p"))
+ (collect alog elog dlog jlog
+ (string->number (cadr args))
+ file (cddr args)))
+ (else
+ (if (null? (cdr args))
+ (collect alog elog dlog jlog port a (cdr args))
+ (usage "serve"))))))
+ (else
+ (cond ((pathname-directory file)
+ => change-directory))
+ (load file)
+ (when port (server-port port))
+ (when alog
+ (access-log
+ (cond ((equal? alog "-") (current-output-port))
+ ((equal? alog "") #f)
+ (else alog))))
+ (when jlog
+ (ajax-log
+ (cond ((equal? jlog "-") (current-output-port))
+ ((equal? jlog "") #f)
+ (else jlog))))
+ (when elog
+ (error-log
+ (cond ((equal? elog "-") (current-error-port))
+ ((equal? elog "") #f)
+ (else elog))))
+ (when dlog
+ (debug-log
+ (cond ((equal? dlog "-") (current-error-port))
+ ((equal? dlog "") #f)
+ (else dlog))))
+ (fprintf (current-error-port)
+ "chickadee server listening on :~a\n" (server-port))
+ (chickadee-start-server)))
+
+ ))
+ (("location") ;; accept conf file?
+ (print "conf: " +conf-file+)
+ (print "base: " +basedir+))
+ (("help" cmd)
+ (usage cmd))
+ (else (usage "help")))
+
+
+
View
28 chickadee-config-nginx.scm
@@ -0,0 +1,28 @@
+(use chickadee spiffy uri-common)
+(define uri uri-reference)
+
+(root-path "root")
+(server-port 8383)
+(max-connections 8)
+
+(access-log "logs/access.log")
+(error-log "logs/error.log")
+(debug-log (current-error-port))
+(ajax-log #f) ;; Slow; not recommended for production.
+
+(cdoc-uri (uri "/cdoc"))
+(chickadee-uri (uri "/chickadee"))
+(incremental-search-uri (uri "/cdoc/ajax/prefix"))
+(chickadee-css-files (list (uri "/cdoc/chickadee.css")))
+(chickadee-js-files (list (uri "http://code.jquery.com/jquery-1.4.2.min.js")
+ (uri "/cdoc/jquery.metadata.2.1.min.js")
+ (uri "/cdoc/chickadee-jquery.js")))
+
+(maximum-match-results 250)
+(maximum-match-signatures 100)
+(incremental-search 15)
+(incremental-search-delay 50)
+(cache-nodes-for 600)
+(cache-static-content-for 1800)
+
+(last-modified (current-seconds))
View
47 chickadee-config.scm
@@ -0,0 +1,47 @@
+;;; Chickadee chicken-doc server configuration file
+
+;; chickadee changes to the directory holding the conf-file on startup,
+;; so all paths below are relative to that path.
+
+(use chickadee spiffy uri-common) ;; REQUIRED. Do not remove.
+(define uri uri-reference) ;; A convenient alias.
+
+;;; Main config
+
+(root-path "root")
+(server-port 8080)
+
+;; Logging. If commented out, the defaults will be used:
+;; access, debug and AJAX logs are disabled, and error logs go to stderr.
+
+;(access-log "logs/access.log")
+;(error-log "logs/error.log")
+;(debug-log (current-error-port))
+;(ajax-log "logs/ajax.log") ;; CPU intensive; not recommended for production.
+
+;; An even number of connections is desirable as user agents
+;; usually open two (keep-alive) connections per hostname.
+(max-connections 8)
+(cdoc-uri (uri "/cdoc"))
+(chickadee-uri (uri "/chickadee"))
+(incremental-search-uri (uri "/cdoc/ajax/prefix"))
+(chickadee-css-files (list (uri "/cdoc/chickadee.css")))
+(chickadee-js-files (list (uri "http://code.jquery.com/jquery-1.4.2.min.js")
+ (uri "/cdoc/jquery.metadata.2.1.min.js")
+ (uri "/cdoc/chickadee-jquery.js")))
+
+(maximum-match-results 250)
+(maximum-match-signatures 100)
+(incremental-search 15)
+(incremental-search-delay 50)
+(cache-nodes-for 300)
+(cache-static-content-for 1800)
+
+(last-modified (current-seconds))
+
+;;; debugging
+
+(%chickadee:debug-incremental-search-latency 0)
+
+;;; start
+
View
3  chickadee.scm
@@ -595,6 +595,9 @@
((and (incremental-search-uri)
(equal? (uri-path (incremental-search-uri)) p))
=> incremental-search-handler)
+ ;; Last resort redirect of root path to main page.
+ ((equal? p '(/ ""))
+ (redirect-to (path->href '())))
(else
(continue)))))))))
View
38 chickadee.setup
@@ -1,11 +1,47 @@
+;; -*- scheme -*-
+
+(define +version+ "0.9.8")
+
(compile -s -O2 -d1 -S chicken-doc-html.scm -j chicken-doc-html)
(compile -s -O2 -d0 chicken-doc-html.import.scm)
(compile -s -O2 -d1 -S chickadee.scm -j chickadee)
(compile -s -O2 -d0 chickadee.import.scm)
+(compile -O2 -d0 -S -o chickadee chickadee-cmd.scm)
(install-extension
'chickadee
'("chickadee.so" "chicken-doc-html.so" "chickadee.import.so"
"chicken-doc-html.import.so")
- `((version "0.9.7")))
+ `((version ,+version+)))
+(install-program
+ 'chickadee-cmd
+ '("chickadee")
+ `((version ,+version+)))
+
+;; Tree installation
+
+(if (not (setup-install-mode))
+ (exit))
+
+(define +basedir+ (make-pathname (chicken-home) "chickadee"))
+(define +root+ (make-pathname +basedir+ "root"))
+(define +cdoc+ (make-pathname +root+ "cdoc"))
+
+(create-directory +basedir+)
+(create-directory +root+)
+(create-directory +cdoc+)
+(create-directory (make-pathname +basedir+ "logs"))
+(copy-file "chickadee-jquery.js" +cdoc+)
+(copy-file "chickadee.css" +cdoc+)
+(copy-file "jquery.metadata.min.js"
+ (make-pathname +cdoc+
+ "jquery.metadata.2.1.min.js"))
+(copy-file "mag.png" +cdoc+)
+(copy-file "chickadee-config.scm"
+ (make-pathname +basedir+
+ "config.scm"))
+(copy-file "chickadee-config-nginx.scm"
+ (make-pathname +basedir+
+ "config-nginx.scm"))
+
View
4 install.sh
@@ -1,8 +1,10 @@
#!/bin/bash
-DEST=./root/cdoc
+BASE=.
+DEST=$BASE/root/cdoc
mkdir -p $DEST
+mkdir -p $BASE/logs
ln -f chickadee-jquery.js $DEST
ln -f chickadee.css $DEST
ln -f jquery.metadata.min.js $DEST/jquery.metadata.2.1.min.js
Please sign in to comment.
Something went wrong with that request. Please try again.