making server buildable
This commit is contained in:
		
							parent
							
								
									bc15f05603
								
							
						
					
					
						commit
						ec3bde1191
					
				
					 6 changed files with 85 additions and 17 deletions
				
			
		
							
								
								
									
										16
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
all: build-server
 | 
			
		||||
 | 
			
		||||
build-server:
 | 
			
		||||
	sbcl --eval '(ql:quickload "deploy")' --eval '(asdf:load-asd "/home/chris/dev/tfcconnection/tfcserver.asd")' --eval '(ql:quickload :tfcserver)' --eval '(push :deploy-console *features*)' --eval "(asdf:make :tfcserver)" --eval '(quit)'
 | 
			
		||||
 | 
			
		||||
serve:
 | 
			
		||||
	hugo server --noHTTPCache
 | 
			
		||||
 | 
			
		||||
css:
 | 
			
		||||
	NODE_ENV=development ./themes/blowfish/node_modules/tailwindcss/lib/cli.js -c ./themes/blowfish/tailwind.config.js -i ./themes/blowfish/assets/css/main.css -o ./assets/css/compiled/main.css --jit -w
 | 
			
		||||
 | 
			
		||||
build-site:
 | 
			
		||||
	rm -rf public && NODE_ENV=production ./themes/blowfish/node_modules/tailwindcss/lib/cli.js -c ./themes/blowfish/tailwind.config.js -i ./themes/blowfish/assets/css/main.css -o ./assets/css/compiled/main.css --jit && hugo --gc --minify
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf public
 | 
			
		||||
							
								
								
									
										26
									
								
								default.nix
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								default.nix
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,9 +2,25 @@
 | 
			
		|||
  stdenv,
 | 
			
		||||
  lib,
 | 
			
		||||
  hugo,
 | 
			
		||||
  go
 | 
			
		||||
  go,
 | 
			
		||||
  sbcl,
 | 
			
		||||
  sbclPackages,
 | 
			
		||||
  makeWrapper,
 | 
			
		||||
  openssl
 | 
			
		||||
}:
 | 
			
		||||
 | 
			
		||||
let
 | 
			
		||||
  sbcl' = sbcl.withPackages (ps: with ps; [
 | 
			
		||||
    hunchentoot
 | 
			
		||||
    dexador
 | 
			
		||||
    clack
 | 
			
		||||
    jzon
 | 
			
		||||
    serapeum
 | 
			
		||||
    openssl
 | 
			
		||||
    openssl.out
 | 
			
		||||
    openssl.dev
 | 
			
		||||
  ]);
 | 
			
		||||
in
 | 
			
		||||
stdenv.mkDerivation rec {
 | 
			
		||||
  name = "tfcconnection";
 | 
			
		||||
  pname = "tfcconnection";
 | 
			
		||||
| 
						 | 
				
			
			@ -12,16 +28,22 @@ stdenv.mkDerivation rec {
 | 
			
		|||
 | 
			
		||||
  src = ./.;
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    makeWrapper
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  buildInputs = [
 | 
			
		||||
    hugo
 | 
			
		||||
    go
 | 
			
		||||
    sbcl'
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  buildPhase = ''
 | 
			
		||||
  hugo
 | 
			
		||||
  make
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
  
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
        in 
 | 
			
		||||
        {
 | 
			
		||||
          devShell = import ./shell.nix { inherit pkgs; };
 | 
			
		||||
          defaultPackage = pkgs.callPackage ./default.nix { };
 | 
			
		||||
        }
 | 
			
		||||
      );
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,6 @@
 | 
			
		|||
(require :asdf)
 | 
			
		||||
(require :hunchentoot)
 | 
			
		||||
(require :dexador)
 | 
			
		||||
(require :serapeum)
 | 
			
		||||
(require :clack)
 | 
			
		||||
(require :com.inuoe.jzon)
 | 
			
		||||
;; (load "~/quicklisp/setup.lisp")
 | 
			
		||||
;; (ql:quickload :cffi :silent t)
 | 
			
		||||
;; (ql:quickload '(hunchentoot clack dexador com.inuoe.jzon serapeum))
 | 
			
		||||
(ql:quickload '(hunchentoot clack dexador com.inuoe.jzon serapeum bordeaux-threads))
 | 
			
		||||
 | 
			
		||||
(uiop:define-package tfc-server
 | 
			
		||||
(defpackage tfc-server
 | 
			
		||||
  (:use :cl :uiop :com.inuoe.jzon :clack))
 | 
			
		||||
 | 
			
		||||
(in-package :tfc-server)
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +11,10 @@
 | 
			
		|||
(defvar *stream*)
 | 
			
		||||
(defvar *auth-token* "boFFRM68vvXbO-DO7S9YDg86lHX027-hd07mn0dh")
 | 
			
		||||
 | 
			
		||||
(defvar *server* (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
 | 
			
		||||
(defvar *server*)
 | 
			
		||||
 | 
			
		||||
(defun start-server (port)
 | 
			
		||||
  (setq *server* (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port port))))
 | 
			
		||||
 | 
			
		||||
(defun post-health-form (data-list)
 | 
			
		||||
  "Takes the health form as an alist and posts it to nocodb"
 | 
			
		||||
| 
						 | 
				
			
			@ -55,9 +50,9 @@
 | 
			
		|||
 | 
			
		||||
(defun process-form (form)
 | 
			
		||||
  "Processes the form and sends it on"
 | 
			
		||||
    (uiop:println "---")
 | 
			
		||||
    (maphash 'print-hash-entry form)
 | 
			
		||||
    (uiop:println "---"))
 | 
			
		||||
  (uiop:println "---")
 | 
			
		||||
  (maphash 'print-hash-entry form)
 | 
			
		||||
  (uiop:println "---"))
 | 
			
		||||
 | 
			
		||||
(defun save-string-file (string file-path)
 | 
			
		||||
  "save a file that is represented as a string to disk that came from a multipart/form-data"
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +81,7 @@
 | 
			
		|||
             (setq *last-list-data* nil)
 | 
			
		||||
             (loop :for i :in *last-data*
 | 
			
		||||
                   :do (let* ((content-disposition (nth 1
 | 
			
		||||
                                            (serapeum:lines i :eol-style :crlf :honor-crlf t)))
 | 
			
		||||
                                                        (serapeum:lines i :eol-style :crlf :honor-crlf t)))
 | 
			
		||||
                              (start (if content-disposition (position #\" content-disposition)))
 | 
			
		||||
                              (end (if start (position #\" content-disposition :start (1+ start)) nil))
 | 
			
		||||
                              (name (if end (if start (subseq content-disposition (1+ start) end) nil) nil))
 | 
			
		||||
| 
						 | 
				
			
			@ -136,3 +131,19 @@
 | 
			
		|||
             (post-health-form *last-list-data*)
 | 
			
		||||
             (format nil "thankyou"))))))
 | 
			
		||||
 | 
			
		||||
(defun main ()
 | 
			
		||||
  (start-server 4242)
 | 
			
		||||
  (format t "Server has started on port 4242~&")
 | 
			
		||||
  (handler-case (bt:join-thread (find-if (lambda (th)
 | 
			
		||||
                                           (search "hunchentoot" (bt:thread-name th)))
 | 
			
		||||
                                         (bt:all-threads)))
 | 
			
		||||
    (#+sbcl sb-sys:interactive-interrupt
 | 
			
		||||
     #+ccl  ccl:interrupt-signal-condition
 | 
			
		||||
     #+clisp system::simple-interrupt-condition
 | 
			
		||||
     #+ecl ext:interactive-interrupt
 | 
			
		||||
     #+allegro excl:interrupt-signal
 | 
			
		||||
     () (progn
 | 
			
		||||
          (format *error-output* "Aborting.~&")
 | 
			
		||||
          (hunchentoot:stop *server*)
 | 
			
		||||
          (uiop:quit)))
 | 
			
		||||
    (error (c) (format t "Woops, an unknown error occured:~&~a~&" c))))
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 679 KiB  | 
							
								
								
									
										18
									
								
								tfcserver.asd
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tfcserver.asd
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
#-asdf3.1 (error "requires asdf 3.1")
 | 
			
		||||
 | 
			
		||||
(defsystem "tfcserver"
 | 
			
		||||
  :version "0.1.0"
 | 
			
		||||
  :author "Chris Cochrun"
 | 
			
		||||
  :license "AGPLV3"
 | 
			
		||||
  :depends-on ("hunchentoot" "dexador" "serapeum" "clack" "com.inuoe.jzon" "bordeaux-threads")  ;; <== list of Quicklisp dependencies
 | 
			
		||||
  :components ((:module "src"
 | 
			
		||||
                :components
 | 
			
		||||
                ((:file "main"))))
 | 
			
		||||
  :description "Restful server to handle website pieces"
 | 
			
		||||
  :long-description "Restful server to handle website pieces"
 | 
			
		||||
  ;; :in-order-to ((test-op (test-op "tfcserver-test")))
 | 
			
		||||
  :defsystem-depends-on (:deploy)  ;; (ql:quickload "deploy") before
 | 
			
		||||
  :build-operation "deploy-op" ;; leave as is
 | 
			
		||||
  :build-pathname "tfcapi"
 | 
			
		||||
  :entry-point "tfc-server::main"
 | 
			
		||||
  )
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue