From 18033a8db71800f341b86e38d36a2df8a344ccf5 Mon Sep 17 00:00:00 2001 From: Alex Oloo Date: Tue, 6 Jul 2021 14:04:31 +0200 Subject: [PATCH] remove cluster stuff --- README.md | 1 - install.sh | 21 +++++++----------- project.clj | 2 +- resources/PCP_VERSION | 2 +- src/pcp/core.clj | 1 - src/pcp/scgi.clj | 45 +++++++++++++-------------------------- src/pcp/utility.clj | 2 +- test/pcp/utility_test.clj | 2 +- 8 files changed, 27 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 021cb39..976ce77 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,6 @@ Going above 400 req/s generally results in bad things happening. You can test yo ## Release 0.0.2 - [ ] Perfomance improvements -- [ ] Cluster mode ## Release 0.1.0 - [ ] Store passphrases with [konserve](https://github.com/replikativ/konserve) diff --git a/install.sh b/install.sh index 7ebd6f9..a0567d6 100644 --- a/install.sh +++ b/install.sh @@ -12,28 +12,27 @@ print_help() { default_install_dir="/usr/local/bin" install_dir=$default_install_dir -# install_dir_opt=${1:-} -# if [ "$install_dir_opt" ]; then -# install_dir="$install_dir_opt" -# fi +install_dir_opt=${1:-} +if [ "$install_dir_opt" ]; then + install_dir="$install_dir_opt" +fi download_dir=/tmp latest_release="$(curl -sL https://raw.githubusercontent.com/alekcz/pcp/master/resources/PCP_RELEASED_VERSION)" -target_release="${1-$latest_release}" case "$(uname -s)" in Linux*) platform=linux;; Darwin*) platform=macos;; esac -download_url="https://github.com/alekcz/pcp/releases/download/$target_release/pcp-$target_release-$platform-amd64.zip" +download_url="https://github.com/alekcz/pcp/releases/download/$latest_release/pcp-$latest_release-$platform-amd64.zip" cd "$download_dir" echo -e "Downloading $download_url." -curl -o "pcp-$target_release-$platform-amd64.zip" -sL "https://github.com/alekcz/pcp/releases/download/$target_release/pcp-$target_release-$platform-amd64.zip" -unzip -qqo "pcp-$target_release-$platform-amd64.zip" -rm "pcp-$target_release-$platform-amd64.zip" +curl -o "pcp-$latest_release-$platform-amd64.zip" -sL "https://github.com/alekcz/pcp/releases/download/$latest_release/pcp-$latest_release-$platform-amd64.zip" +unzip -qqo "pcp-$latest_release-$platform-amd64.zip" +rm "pcp-$latest_release-$platform-amd64.zip" mkdir -p "/usr/local/etc/pcp-db" mkdir -p "$install_dir/pcp-templates" @@ -53,10 +52,6 @@ mv -f "$download_dir/pcp-server.jar" "$PWD/pcp-server.jar" rm -rf "$PWD/pcp-templates" mv -f "$download_dir/pcp-templates" "$PWD" -if [ ! -e "$PWD/pcp.conf" ] ; then - echo "PCP_CLUSTER=-c" > "$PWD/pcp.conf" -fi - case "$(uname -s)" in Linux*) mv -f "$download_dir/pcp.service" "/etc/systemd/system/pcp.service" diff --git a/project.clj b/project.clj index a59fe3a..d349dce 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject pcp "0.0.2-beta.2" +(defproject pcp "0.0.2-beta.3" :description "PCP: Clojure Processor - A Clojure replacement for PHP" :url "https://github.com/alekcz/pcp" :license {:name "The MIT License" diff --git a/resources/PCP_VERSION b/resources/PCP_VERSION index ddf83ab..f9649f1 100644 --- a/resources/PCP_VERSION +++ b/resources/PCP_VERSION @@ -1 +1 @@ -v0.0.2-beta.2 \ No newline at end of file +v0.0.2-beta.3 \ No newline at end of file diff --git a/src/pcp/core.clj b/src/pcp/core.clj index 65028db..c626deb 100644 --- a/src/pcp/core.clj +++ b/src/pcp/core.clj @@ -201,7 +201,6 @@ (let [scgi-port (Integer/parseInt (or (System/getenv "SCGI_PORT") "9000"))] (case path "" (scgi/serve scgi-handler scgi-port) - "-c" (scgi/serve scgi-handler scgi-port :cluster true) (run-script path))))) \ No newline at end of file diff --git a/src/pcp/scgi.clj b/src/pcp/scgi.clj index 0e76a9d..2a14889 100644 --- a/src/pcp/scgi.clj +++ b/src/pcp/scgi.clj @@ -1,6 +1,5 @@ (ns pcp.scgi - (:require [clojure.string :as str] - [clojure.core.async :as async]) + (:require [clojure.string :as str]) (:import [java.nio.channels ServerSocketChannel SocketChannel Selector SelectionKey] [java.nio ByteBuffer] [java.net InetSocketAddress InetAddress] @@ -103,38 +102,24 @@ serverChannel)) (defn run-selection [active handler ^Selector selector] - (async/thread - (while (some? @active) - (if (not= 0 (.select selector 50)) - (let [keys (.selectedKeys selector)] - (doseq [^SelectionKey key keys] - (let [ops (.readyOps key)] - (cond - (= ops SelectionKey/OP_ACCEPT) (on-accept selector key) - (= ops SelectionKey/OP_READ) (on-read key handler)))) - (.clear keys)) - nil)))) + (while (some? @active) + (if (not= 0 (.select selector 50)) + (let [keys (.selectedKeys selector)] + (doseq [^SelectionKey key keys] + (let [ops (.readyOps key)] + (cond + (= ops SelectionKey/OP_ACCEPT) (on-accept selector key) + (= ops SelectionKey/OP_READ) (on-read key handler)))) + (.clear keys)) + nil))) -(defn serve [handler port &{:keys [cluster]}] +(defn serve [handler port] (let [active (atom true) ^Selector selector (Selector/open) - ^Selector selector2 (when cluster (Selector/open)) - ^Selector selector3 (when cluster (Selector/open)) - ^Selector selector4 (when cluster (Selector/open)) - ^ServerSocketChannel server (build-server port selector) - ^ServerSocketChannel server2 (when cluster (build-server 9007 selector2)) - ^ServerSocketChannel server3 (when cluster (build-server 9014 selector3)) - ^ServerSocketChannel server4 (when cluster (build-server 9021 selector4))] - (run-selection active handler selector) - (when cluster - (run-selection active handler selector2) - (run-selection active handler selector3) - (run-selection active handler selector4)) - (future (while (some? @active) nil)) + ^ServerSocketChannel server (build-server port selector)] + (future + (run-selection active handler selector)) (fn [] (.close server) - (when cluster (.close server2)) - (when cluster (.close server3)) - (when cluster (.close server4)) (reset! active false)))) diff --git a/src/pcp/utility.clj b/src/pcp/utility.clj index 22df0d1..cbea171 100644 --- a/src/pcp/utility.clj +++ b/src/pcp/utility.clj @@ -19,7 +19,7 @@ (def root (atom nil)) (def scgi (atom "9000")) -(def version "v0.0.2-beta.2") +(def version "v0.0.2-beta.3") (defn keydb [] (or (env :pcp-keydb) "/usr/local/etc/pcp-db")) diff --git a/test/pcp/utility_test.clj b/test/pcp/utility_test.clj index 1d9cf36..ec141d3 100644 --- a/test/pcp/utility_test.clj +++ b/test/pcp/utility_test.clj @@ -152,7 +152,7 @@ _ (io/make-parents (str "./test-resources/pcp-db/" project ".db")) _ (new-folder root) _ (utility/stop-scgi) - scgi (core/-main "-c") + scgi (core/-main) local (utility/-main "-s" root) _ (Thread/sleep 2000) file-eval (json/decode (with-out-str (utility/-main "-e" (str root "/index.clj"))) true)