Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created October 3, 2013 17:05
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save andrewvc/6813268 to your computer and use it in GitHub Desktop.
Save andrewvc/6813268 to your computer and use it in GitHub Desktop.
Upstart script for elasticsearch on ubuntu.... that actually works. Install the deb, and then run `sudo update-rc.d elasticsearch remove -f` to disable the init script.
# ElasticSearch upstart script
description "ElasticSearch service"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
respawn
respawn limit 10 30
# NB: Upstart scripts do not respect
# /etc/security/limits.conf, so the open-file limits
# settings need to be applied here.
limit nofile 32000 32000
setuid elasticsearch
setgid elasticsearch
exec /usr/share/elasticsearch/bin/elasticsearch -f -Des.default.config=/etc/elasticsearch/elasticsearch.yml -Des.default.path.home=/usr/share/elasticsearch/ -Des.default.path.logs=/var/log/elasticsearch/ -Des.default.path.data=/var/lib/elasticsearch/ -Des.default.path.work=/tmp/elasticsearch -Des.default.path.conf=/etc/elasticsearch
@spacemunkay
Copy link

Thanks for sharing! FYI, invalid option "-f"

@redmar
Copy link

redmar commented Jul 9, 2015

on ubuntu 14.04, the call to update-rc.d should be sudo update-rc.d -f elasticsearch remove

@nickjbauer
Copy link

Its mind boggling that elastic.co hasn't done something like this yet. Just tried this gist on 2.2.1, but it wasn't working, so i replaced the last line with this:
/usr/share/elasticsearch/bin/elasticsearch -d --default.path.home=/usr/share/elasticsearch/ --default.path.data=/var/lib/elasticsearch/ --default.path.conf=/etc/elasticsearch --default.path.work=/tmp/elasticsearch --default.path.logs=/var/log/elasticsearch

@frioux
Copy link

frioux commented May 4, 2016

Note @nickjbauer you absolutely do not want the -d there; if you have that there you can't stop the process.

@maslenkov
Copy link

maslenkov commented Jun 26, 2017

Can this gist be updated?

ERROR: Parameter [-f]does not start with --

if remove -f then:

es.default.config is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed.

And any ideas how can I debug starting process? Because it doesn't work for me with initctl even if works for me with shell...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment