https://github.com/zk/leiningen-init-script
A leiningen plugin that generates *NIX daemon scripts.
https://github.com/zk/leiningen-init-script
Last synced: 13 days ago
JSON representation
A leiningen plugin that generates *NIX daemon scripts.
- Host: GitHub
- URL: https://github.com/zk/leiningen-init-script
- Owner: zk
- Created: 2010-04-29T05:17:31.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2010-06-27T22:35:21.000Z (over 15 years ago)
- Last Synced: 2025-07-06T22:04:22.693Z (6 months ago)
- Language: Clojure
- Homepage:
- Size: 101 KB
- Stars: 24
- Watchers: 2
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# leiningen-init-script
A leiningen plugin that generates *NIX init scripts. Alpha quality, verified working on OSX 10.6 and FC12.
In a nutshell, LSI generates the following artifacts which can be found in your /init-script dir:
* Project Uberjar
* d script
Paired down from the Fedora Core init script template, injected with values from your lein project.clj.
* install- script
Creates (but does not overwrite) the :pid-dir, :install-dir, and :init-script-dir directories. To override the defaults see the Configuration section below.
* clean- script
Removes the init script, and uberjar from their respective install paths. Does not remove any created directories.
If you have an feature suggestions / bug reports, please open up an [issue](https://github.com/zkim/leiningen-init-script/issues)
## Why?
Because it was too damn time-consuming to turn a java program into a *nix daemon service that can be started / stopped asyncronously, chkconfig'd, etc.
## Lein
Add [leiningen-init-script "1.2.0-SNAPSHOT"] to the :dev-dependencies section in your project.clj.
## Configuration
leiningen-init-script takes several options in the form of:
{:name "override-project-name"
:pid-dir "/var/run"
:install-dir "/usr/local/my-project-name"
:init-script-dir "/etc/init.d"
:redirect-output-to "/log/file or /dev/null"
:properties {:clj-config.env "dev"
:java.library.path "/some/dir"
:init.script.test.prop "prop with spaces"}
:java-opts ["-server"
"-Xms256M"
"-Xmx512M"
"-XX:MaxPermSize=128M"]}
which are passed to the the init-script task by adding a :lis-opts entry to the project map. For example:
(defproject init-script-test "0.1.0"
:description "Test project for leiningen-init-script"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]]
:dev-dependencies [[leiningen-init-script "1.2.0-SNAPSHOT"]]
:lis-opts {:redirect-output-to "/var/log/init-script-test.log"
:properties {:clj-config.env "dev"
:java.library.path "/some/dir"
:init.script.test.prop "prop with spaces"}
:java-opts ["-server"
"-Xms256M"
"-Xmx512M"
"-XX:MaxPermSize=128M"]}
:main main)
## Usage
### Short Version
Create a main class for your project, run lein init-script, and check the ./init-script directory.
### Long Version
#### Taken from the [init-script-test](http://github.com/zkim/init-script-test) project.
Clone the init-script-test repo
git clone git://github.com/zkim/init-script-test.git
cd into the cloned repo directory
cd init-script-test
Download dependencies
lein deps
Run the init-script task
lein init-script
Your output should look something like:
Created /Users/zkim/tmp/init-script-test/init-script-test.jar
Including init-script-test.jar
Including clojure-1.1.0.jar
Including clojure-contrib-1.1.0.jar
Including leiningen-init-script-0.1.0.jar
*** Done generating init scripts, see the /Users/zkim/tmp/init-script-test/init-script/ directory
napple:init-script-test zkim$
cd into the init-script directory
cd ./init-script
Make install-init-script-test, clean-init-script-test runnable
chmod u+x ./install-init-script-test
chmod u+x ./clean-init-script-test
Install init script and jar
sudo ./install-init-script-test
leiningen-init-script installs the jar to /usr/local/ and the init script to /etc/init.d. These defaults can be changed, see the Configuration section of the [leiningen-init-script](http://github.com/zkim/leiningen-init-script) README
Start the daemon service
sudo /etc/init.d/init-script-testd start
Verify the jar is running
ps -e
Output:
44678 ttys003 0:00.01 login -pf zkim
44679 ttys003 0:00.11 -bash
45216 ttys003 0:01.28 /usr/bin/java -jar /usr/local/init-script-test/init-script-test-standalone.jar
45225 ttys003 0:00.00 ps -e
Stop the daemon service and verify the process has stopped
sudo /etc/init.d/init-script-testd stop
ps -e
44198 ttys002 0:00.09 -bash
44678 ttys003 0:00.01 login -pf zkim
44679 ttys003 0:00.11 -bash
45248 ttys003 0:00.00 ps -e
## Limitations
No Windows support at this time, if you'd like to see support for windows services, please open up an issue.
## License
[Eclipse Public License v1.0](http://www.eclipse.org/legal/epl-v10.html)