H2 Databaseを使ってデータベースアプリケーションを作るときに、サーバーモードでH2 Databaseを起動するのが少々面倒だったので、leiningenのプラグインを作りました。
使い方
- project.cljにプラグインを追加。
:plugins [[jkugiya/h2-tools "0.1.0-SNAPSHOT"]]
- project.cljにH2 Databaseを起動するためのパラメータを追加
:h2-tools {
web: {
:allow-others? false ;; -webAllowOthers
:daemon? true ;; -webDaemon
:port 8082;; -webPort
:ssl? false ;; -webSSL
}
tcp: {
:allow-others? false ;; -tcpAllowOthers
:daemon? true ;; -tcpDaemon
:port 9092 ;; -tcpPort
:ssl? false ;; -tcpSSL
:password "passpass" ;; -tcpPassword
:shutdown "tcp://localhost" ;; -tcpShutdown
:shutdown-force? true ;; -tcpShutdownForce
}
pg: {
:allow-others? false ;; -pgAllowOthers
:daemon? true ;; -pgDaemon
:port 5435 ;; -pgPort
}
ftp: {
:port 7070 ;; -ftpPort
:dir "/home/ftp" ;; -ftpDir
:write "write-user" ;; -ftpWrite
:write-password "write-p@ss" ;; -ftpWritePassword
:read "read-user" ;; -ftpRead
:task? false ;; -ftpTask
}
:trace? false ;; -trace
:if-exists? ;; -IfExists
:base-dir "/path/to/database" ;; -baseDir
:key ["from" "to"] ;; -key
:properties "~" ;; -properties
}
- 色々パラメータがありますが、取り敢えず以下で動作します。
:h2-tools {
:web {:port 8082}
:tcp {:port 9092}
:base-dir "/path/to/database"
}
- H2 Databaseの起動
$ lein h2-tools server
バックグラウンドで動くわけではないので、他のleinコマンドを実行するためにはコンソールを別に動かす必要があります。