Skip to content

How to create a destroyer

macourtney edited this page Sep 13, 2010 · 2 revisions

Added in version: 0.6
Updated for version: 0.7

A destroyer is simply a clojure source file in the conjure/script/destroyers directory. The file must have a certain name and contain a specific function or the destroy script will not be able to find it.

As an example, let’s make a hello world destroyer which will simply print “Hello World!” to the screen when called. Our hello world destroyer file must be named “hello_world_destroyer.clj” and be placed in the conjure/script/destroyers directory.

Since hello_world_destroyer.clj is in the conjure/script/destroyers directory it’s namespace must be:

(ns conjure.script.destroyers.hello-world-destroyer)

All destroyers must contain a function named “destroy” which takes exactly one parameter usually called “params”. Params is the list of all command line options passed to the destroy script after the name of your destroyer (in this case “hello-world”).

Since our hello world destroyer simply prints to the screen, we won’t use params. The complete hello world destroyer looks like:

(ns conjure.script.destroyers.hello-world-destroyer)

(defn
#^{:doc "Simply prints \"Hello World!\" to the console."}
  destroy [params]
  (println "Hello World!"))

To run the hello world destroyer use:

lein conjure destroy hello-world

You should then see something like the following on your console:

.\lib\*;.\vendor;.\app;.\config;.\script;.\db;.\test
Initializing environment...
INFO  [conjure.server.server]: Initializing server...
DEBUG [flavors.h2]: Executing query: ["SELECT * FROM sessions LIMIT 1"]
INFO  [conjure.server.server]: Server Initialized.
INFO  [conjure.server.server]: Initializing plugins...
INFO  [conjure.server.server]: Plugins initialized.
Hello World!
Clone this wiki locally