1

I want to start the elasticsearch service on a machine, originally I was going to do this using pallet.actions.service but the documentation says this is now deprecated in favour of pallet.crate.service/service.

However I cannot find any guide to use it to simply start an initd service that is already installed on the node.

Below is my first attempt at getting an es node running using the old service function. Unfortunately I couldn't get this to start the service either, it installed elasticsearch but did not run the service. When I was playing around with this I noticed that it was deprecated:

(def elasticsearch-server
  (server-spec
   :extends [(javacrate/server-spec {})]
   :phases
     {:install (plan-fn
                (add-es-source)
                (package-manager :update)
                (package "elasticsearch")
                (service "elasticsearch" :action :start))}))
shmish111
  • 3,697
  • 5
  • 30
  • 52

1 Answers1

2

I don't recall if service does something extra other than give you an idiomatic interface to service, so what you can do is use exec-script*, which is what I do in my own code without any trouble. In fact, I even do this with Elasticsearch (among other things) and with my services using runit for supervision.

(exec-script* "service elasticsearch start")

Perhaps service does a better job of recovering, though, when the service fails to start? If service elasticsearch start doesn't return 0 then your whole plan will fail.

Gordon Seidoh Worley
  • 7,839
  • 6
  • 45
  • 82
  • 1
    I like the idea of using crates so your code will work on different distros and such, though it's most useful if you are building a crate that will it's self be used on multiple distros. I get frightened every time I see a call to `exec-script` in pallet code. `exec-checked-script` is *always* preferable. – Arthur Ulfeldt May 23 '14 at 20:06