#lang scheme/base
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PLANET.plt - local planet proxy server
;; Bonzai Lab, LLC.  All rights reserved.
;; Licensed under LGPL.
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - a command-line module for starting a planet proxy server
;; yc 1/18/2010 - first version
(require (planet bzlib/shp/start)

;; I will need to figure out how to setup such a site again.... hmm...
;; how do I pass variables into a specific module?
;; can it be *inherited*???
(define (start!)
  (let ((path (or (getenv "BZLIB_PLANET_REPO_PATH") 
        (port 9000))
    (command-line #:program "planet-proxy" 
                  (("-p" "--port") p
                                   "Specify the port - default to 9000"
                                   (assert! p string->number)
                                   (set! port (string->number p)))
                  (("-r" "--repository") 
                   "Specify the repository /var/data/plt/planet-repo"
                   (set! path repo))
                  #:args () 
                  (assert! path directory-exists?)
                  (printf "planet-proxy -r ~a -p ~a\n" path port)
                  (parameterize ((repository-path path))
                    (start-shp-server! (build-path (this-expression-source-directory) "shp")
                                       #:port port

(provide start!)