lmenezes / cerebro

MIT License
5.51k stars 714 forks source link

Please create upstart service for cerebro #87

Open ahazelwood opened 7 years ago

ahazelwood commented 7 years ago

I would love to be able to have cerebro run startup. However I can't figure out how to create a service template for cerebro.

Thanks.

IgorZet commented 7 years ago

I've created /etc/init.d/ script for cerebro. May share it here

Amorik commented 7 years ago

For systemd servers (CentOS 7) you can create service script relatively easily.

vi /etc/systemd/system/cerebro.service

`[Unit] Description=Cerebro

[Service] Type=simple User=root Group=root ExecStart=//bin/cerebro "-Dpidfile.path=/var/run/cerebro.pid" Restart=always WorkingDirectory=/

[Install] WantedBy=multi-user.target`

systemctl daemon-reload systemctl enable cerebro systemctl start cerebro

~Regards

yanyov commented 7 years ago

@ahazelwood For upstart you can use:

description "Cerebro plugin"

start on runlevel [2345] stop on runlevel [06]

script exec start-stop-daemon --start --quiet --exec /usr/local/cerebro-0.6.4/bin/cerebro end script

Just change the path to the bin.

jptoto commented 7 years ago

@Amorik the cerebro.service should be in /usr/lib/systemd/service for Centos 7.x, no?

Amorik commented 7 years ago

@jptoto probably? both work for me, but I'm sure one is more "right" than the other.

hameno commented 7 years ago

My upstart script:

#!upstart
description "Cerebro"

start on startup
stop on shutdown

exec start-stop-daemon --start --make-pidfile --pidfile /var/run/cerebro.pid --chuid cerebro --exec /opt/cerebro/bin/cerebro -- -Dhttp.address=127.0.0.1 >> /var/log/cerebro.log 2>&1

You'll need a cerebro user which owns the cerebro folder.

alkuzad commented 7 years ago

@Amorik I think root is not necessary for cerebro, I strongly recommend to use own user for it's purposes. Also why you set WorkingDirectory to / ?

Amorik commented 7 years ago

@alkuzad Agreed. It was a hasty copy from one of my dev boxes. As for the working directory no reason. In prod it was placed nearby the install folder.

frenkye commented 7 years ago

Hi, if anyone interested I reworked init script for kibana to work for cerebro. Nothing special you just need create user to run cerebro and of course change rights on directory.

cerebro.init.txt

peelman commented 6 years ago

kudos to @Amorik for his systemd script. It works wonderfully on Ubuntu as well.

For reference, my Cerebro lives in /opt, and is symlinked to /opt/current, so my version looks like this:

npeelman@oliver:~$ cat /etc/systemd/system/cerebro.service 
[Unit]
Description=Cerebro

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/cerebro/current/bin/cerebro "-Dpidfile.path=/var/run/cerebro.pid"
Restart=always
WorkingDirectory=/opt/cerebro

[Install]
WantedBy=multi-user.target
npeelman@oliver:~$ 
wols commented 5 years ago
# useradd -r -b /opt -m cerebro
# ll /opt/
drwx------. 2 cerebro cerebro 59 26. Oct 19:40 cerebro
# id cerebro
uid=993(cerebro) gid=990(cerebro) groups=990(cerebro)
# /etc/systemd/system/cerebro.service
...
User=cerebro
Group=cerebro
RuntimeDirectory=cerebro
...