0

I'm creating a pallet crate for elasticsearch. I was stuck on the service not starting however after looking at the logs it seems that it's not really anything to do with pallet. I am using the elasticsearch apt package for 1.0 which includes an init script. If I run sudo service elasticsearch start then ES starts with no problems. If pallet does this for me then it records standard out as having started it successfully

start elasticsearch
 * Starting Elasticsearch Server
   ...done.

However it is not started.

sudo service elasticsearch status
 * elasticsearch is not running

I messed around with the init script and I found if I added sleep 1 after starting the daemon then it works correctly with pallet.

start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS
#this sleep will allow it to work
#sleep 1
log_end_msg $?

I don't understand what is going on?

shmish111
  • 3,697
  • 5
  • 30
  • 52
  • I have the same problem and was not able to fix it, even with the sleep command. But when I run the daemon directly with the parameters it works. This is so weird. – felipeclopes Jan 27 '15 at 18:30

1 Answers1

1

I've seen issues like this before, too. It generally comes down to expecting something to have finished before the script finishes, which may not always happen with services since they fork off background tasks that may still get killed when the ssh connection is terminated.

For these kinds of things you should use Pallet's built in code for running things under supervision. This also has the advantage of making it very easy to switch from plain init.d to runit or daemontools later, which is especially useful for Elasticsearch because it's a JVM process and nearly any JVM will eventually crash if you let it run long enough.

Gordon Seidoh Worley
  • 7,839
  • 6
  • 45
  • 82
  • Cool, can you give me some pointers as to how I use the supervision stuff, I struggle to find documentation for this type of thing for pallet. – shmish111 Aug 25 '14 at 20:53