diff --git a/CHANGELOG.md b/CHANGELOG.md index d9a6271..0efc727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.3.3 +## bugfixes +- fix server shutdown issue + # 0.3.2 ## bugfixes - Fix regexp to match non-english timestamps (Thanks @hso!) diff --git a/Makefile b/Makefile index 1d2c46f..daf1601 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.3.2 +VERSION := 0.3.3 CLJ_FILES := $(shell find . -type f \ \( -path "./test/*" -o -path "./dev/*" -o -path "./src/*" \) \ diff --git a/README.md b/README.md index 720ad07..0d7b98b 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,10 @@ and run it! (double click or from command line, see below). It will open a new b *2019-08-13: MELPA package is pending, see [the melpa pull request](https://github.com/melpa/melpa/pull/6365).* -For the time being, emacs support can be enabled by downloading the [emacs package](https://github.com/rksm/clj-org-analyzer/releases/download/0.3.2/org-analyzer-for-emacs-0.3.2.tar.gz) directly, extracting it and adding it to your load path and require it: +For the time being, emacs support can be enabled by downloading the [emacs package](https://github.com/rksm/clj-org-analyzer/releases/download/0.3.3/org-analyzer-for-emacs-0.3.3.tar.gz) directly, extracting it and adding it to your load path and require it: ```elisp -(add-to-list 'load-path "/path/to/org-analyzer-0.3.2/") +(add-to-list 'load-path "/path/to/org-analyzer-0.3.3/") (require 'org-analyzer) ``` @@ -64,12 +64,12 @@ Afterwards, you can start the tool via `M-x org-analyzer-start`. ## Commandline -Download the latest jar as described above and start it with `java -jar org-analyzer-0.3.2.jar`. +Download the latest jar as described above and start it with `java -jar org-analyzer-0.3.3.jar`. -The following command line options are available, as per `java -jar org-analyzer-0.3.2.jar --help`: +The following command line options are available, as per `java -jar org-analyzer-0.3.3.jar --help`: ``` -Usage: java -jar org-analyzer-0.3.2.jar [opt*] [org-file-or-dir*] +Usage: java -jar org-analyzer-0.3.3.jar [opt*] [org-file-or-dir*] Interactive visualization of timetracking data (org clocks). diff --git a/org-analyzer-el/org-analyzer-pkg.el b/org-analyzer-el/org-analyzer-pkg.el index 3cc4af6..eae00d1 100644 --- a/org-analyzer-el/org-analyzer-pkg.el +++ b/org-analyzer-el/org-analyzer-pkg.el @@ -1,4 +1,4 @@ (define-package "org-analyzer" - "0.3.2" + "0.3.3" "org-analyzer is a tool that extracts time tracking data from org files.") diff --git a/org-analyzer-el/org-analyzer.el b/org-analyzer-el/org-analyzer.el index d726326..9e4b177 100644 --- a/org-analyzer-el/org-analyzer.el +++ b/org-analyzer-el/org-analyzer.el @@ -5,7 +5,7 @@ ;; Author: Robert Krahn ;; URL: https://github.com/rksm/clj-org-analyzer ;; Keywords: calendar -;; Version: 0.3.2 +;; Version: 0.3.3 ;; Package-Requires: ((emacs "24")) ;; Permission is hereby granted, free of charge, to any person obtaining a copy @@ -44,7 +44,7 @@ (defvar org-analyzer-process-buffer nil "The buffer for running the jar.") -(defvar org-analyzer-version "0.3.2" +(defvar org-analyzer-version "0.3.3" "Version to sync with jar.") (defvar org-analyzer-jar-file-name "org-analyzer.jar" diff --git a/org-analyzer-el/org-analyzer.jar b/org-analyzer-el/org-analyzer.jar index 757016e..5d04264 100755 Binary files a/org-analyzer-el/org-analyzer.jar and b/org-analyzer-el/org-analyzer.jar differ diff --git a/pom.xml b/pom.xml index 5e8b4c8..b72b130 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.rksm org-analyzer jar - 0.3.2 + 0.3.3 org-analyzer An app that creates an interactive visualization of org-mode time-tracking data (org clockin). http://github.com/rksm/clj-org-analyzer diff --git a/src/org_analyzer/http_server.clj b/src/org_analyzer/http_server.clj index b370adc..5381bc8 100644 --- a/src/org_analyzer/http_server.clj +++ b/src/org_analyzer/http_server.clj @@ -1,9 +1,10 @@ (ns org-analyzer.http-server (:require [clojure.edn :as edn] [clojure.java.io :as io] + [clojure.pprint :refer [cl-format]] [clojure.set :as set :refer [rename-keys]] [clojure.string :as s] - [compojure.core :refer [routes GET POST]] + [compojure.core :refer [GET POST routes]] [compojure.handler :as handler] [compojure.route :as route] [java-time :as time] @@ -18,8 +19,7 @@ [ring.middleware.stacktrace :refer [wrap-stacktrace]] [ring.util.response :as response]) (:import java.io.File - java.lang.Thread - [java.time LocalDateTime ZoneId])) + java.lang.Thread)) ;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -113,18 +113,32 @@ ;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- (defn start-kill-countdown! + "(:opts @app-state) has two fields kill-when-client-disconnects? and + kill-remorse-period. If kill-when-client-disconnects? option is truthy, will + set (:am-i-about-to-kill-myself? @app-state) to true and start a countdown for + kill-remorse-period milliseconds. If after the + timeout (:am-i-about-to-kill-myself? @app-state) is still true, it will exit + the program. + + `start-kill-countdown!` will be triggered when a client exists. If a new + client is started, it will cancel the kill countdown. This allows us to stop + servers that were started via double click and not via a terminal or other + means that would control the java process." [app-state] (let [{{:keys [kill-when-client-disconnects? kill-remorse-period]} :opts} @app-state] (if-not kill-when-client-disconnects? "Server kill is disabled" - (do (println "Client requested kill. Will stop server in 5 seconds.") - (swap! app-state assoc :am-i-about-to-kill-myself? true) - (future - (Thread/sleep (-> @app-state :opts :kill-when-client-disconnects?)) - (if (-> @app-state :am-i-about-to-kill-myself?) - (System/exit 0) - (println "kill canceled"))) - "OK")))) + (let [msg (cl-format nil + "Client requested kill. Will stop server in ~d second~:*~P" + (quot kill-remorse-period 1000))] + (println msg) + (swap! app-state assoc :am-i-about-to-kill-myself? true) + (future + (Thread/sleep kill-remorse-period) + (if (-> @app-state :am-i-about-to-kill-myself?) + (System/exit 0) + (println "kill canceled"))) + msg)))) (defn stop-kill-countdown! [app-state] @@ -147,7 +161,6 @@ files (rename-keys (group-by #(.exists %) files) {false :non-existing true :existing}) response (into {} (map (fn [[key files]] [key (seq (map #(.getCanonicalPath %) files))]) files))] (swap! app-state assoc :org-files-and-dirs (:existing files)) - (prn response) (pr-str response))) (defn http-get-clocks [app-state from to]