Changeset 3313

Show
Ignore:
Timestamp:
06/24/08 16:56:54 (7 months ago)
Author:
hans
Message:

hot frontend fixes. works with release varnishd now.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bknr/web/src/frontend/frontend.lisp

    r3312 r3313  
    77             (format stream "BKNR web frontend is already running.")))) 
    88 
    9 (defvar *frontend-pid-file* #P"bknr-web-frontend.pid") 
     9(defvar *varnish-directory*) 
     10 
     11(defparameter *frontend-verbose* nil) 
     12(defparameter *frontend-debug* nil) 
     13 
     14(defun execute-shell (fmt &rest args) 
     15  (let ((command (apply #'format nil fmt args))) 
     16    (when *frontend-debug* 
     17      (format t "; $ ~A~%" command)) 
     18    (asdf:run-shell-command command))) 
     19 
     20(defun frontend-pid-file () 
     21  (merge-pathnames #P"bknr-web-frontend.pid" *varnish-directory*)) 
    1022 
    1123(defun read-pid-file () 
    12   (with-open-file (in *frontend-pid-file*) 
     24  (asdf:run-shell-command (format nil "sudo chmod 644 ~A" (namestring (frontend-pid-file)))) 
     25  (with-open-file (in (frontend-pid-file)) 
    1326    (read in))) 
    1427 
    1528(defun frontend-running-p () 
    16   (and (probe-file *frontend-pid-file*) 
    17        (zerop (asdf:run-shell-command "sudo kill -0 ~D" (read-pid-file))))) 
    18  
    19 (defun start-frontend (&key 
    20                        host 
    21                        backend-port 
    22                        (varnish-directory (namestring (format nil "/tmp/varnish-~A/" backend-port))) 
    23                        (port 80)) 
    24   (when (frontend-running-p) 
    25     (cerror "Tear it down!" 'frontend-already-running) 
    26     (stop-frontend :verbose t) 
    27     (assert (not (frontend-running-p)) nil 
    28             "Failed to stop frontend. This is a bug.")) 
    29   (let* ((cmd (format nil "sudo varnishd -a ~@[~A~]:~D ~ 
    30                                    -b localhost:~D ~ 
    31                                    -n '~A' ~ 
    32                                    -P '~A'" 
    33                       host port 
    34                       backend-port 
    35                       varnish-directory 
    36                       *frontend-pid-file*)) 
    37          (exit-code (progn (format t "; $ ~A" cmd) 
    38                            (asdf:run-shell-command cmd)))) 
    39     (unless (zerop exit-code) 
    40       (error "Attempt to launch varnishd returned error ~D." exit-code))) 
    41   (values)) 
     29  (and (probe-file (frontend-pid-file)) 
     30       (zerop (execute-shell "sudo kill -0 ~D" (read-pid-file))))) 
    4231 
    4332(defun stop-frontend (&key verbose) 
     
    4534    ((frontend-running-p) 
    4635     (when verbose (format t "~&; Stopping frontend with PID ~D..." (read-pid-file))) 
    47      (asdf:run-shell-command "sudo kill ~D" (read-pid-file)) 
     36     (execute-shell "sudo kill ~D" (read-pid-file)) 
    4837     (dotimes (i 10 
    4938               (error "Frontend could not be stopped")) 
     
    5544  (values)) 
    5645 
     46(defun start-frontend (&key 
     47                       host 
     48                       backend-port 
     49                       (verbose t) 
     50                       (varnish-directory (pathname (format nil "/tmp/varnish-~A/" backend-port))) 
     51                       (port 80)) 
     52  (let ((*varnish-directory* varnish-directory) 
     53        (*frontend-verbose* verbose)) 
     54    (when (frontend-running-p) 
     55      #+(or) (cerror "Stop the running frontend process" 'frontend-already-running) 
     56      (stop-frontend :verbose verbose) 
     57      (assert (not (frontend-running-p)) nil 
     58              "Failed to stop frontend. This is a bug.")) 
     59    (when verbose 
     60      (format t "; Starting varnishd frontend process on ~@[~A~]:~A~%" host port)) 
     61    (let ((exit-code (execute-shell "sudo varnishd -a ~@[~A~]:~D ~ 
     62                                   -b localhost:~D ~ 
     63                                   -n '~A' ~ 
     64                                   -P '~A'" 
     65                                    host port 
     66                                    backend-port 
     67                                    (namestring varnish-directory) 
     68                                    (namestring (frontend-pid-file))))) 
     69      (unless (zerop exit-code) 
     70        (error "Attempt to launch varnishd exit code ~D." exit-code))) 
     71    (values))) 
     72 
  • trunk/projects/lisp-ecoop/src/load.lisp

    r3309 r3313  
    22(in-package :cl-user) 
    33 
    4 #+sbcl(require 'asdf) 
    5 #+sbcl(require 'sb-posix) 
    6 #+sbcl(assert (eql sb-impl::*default-external-format* :utf-8)) 
     4#+sbcl (require 'asdf) 
     5#+sbcl (require 'sb-posix) 
     6#+sbcl (assert (eql sb-impl::*default-external-format* :utf-8)) 
    77 
    88(load (compile-file "../../../thirdparty/asdf/asdf.lisp"))