[ 
https://issues.apache.org/jira/browse/CASSANDRA-13436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16067859#comment-16067859
 ] 

Murukesh Mohanan commented on CASSANDRA-13436:
----------------------------------------------

I had a look at the current init script, and tried writing a systemd 
equivalent. This raised some questions:

1. The part that doesn't easily translate to systemd is the JVM search code 
(which searches for Java in certain directories and sets the command and 
{{JAVA_HOME}} appropriately. Perhaps we should leave it to the system 
administrator to set it in {{/etc/default/cassandra}}?
2. The PID file becomes unnecessary since systemd can track the processes 
started by a service. But I'm not sure if nothing outside the init script uses 
the PID file.
3. The log file could also be considered unnecessary since systemd-journald 
will gather up any output. But, again, people might expect the logs to stored 
in {{/var/log/cassandra/cassandra.log}}. 

So, we could have a  minimal systemd unit like so (running cassandra in the 
foreground making it a simple service):

{code}
[Unit]
Description=Cassandra is a distributed storage system for structured data.

[Service]
Environment=CASSANDRA_HOME=/usr/share/cassandra 
CASSANDRA_CONF=/etc/cassandra/conf 
CASSANDRA_INCLUDE=/usr/share/cassandra/cassandra.in.sh
EnvironmentFile=-/etc/default/cassandra
User=cassandra
ExecStart=/usr/sbin/cassandra -f
TimeoutStopSec=25
SuccessExitStatus=0 143

[Install]
WantedBy=multi-user.target
{code}

Or more verbose:

{code}
[Unit]
Description=Cassandra is a distributed storage system for structured data.

[Service]
Environment=CASSANDRA_HOME=/usr/share/cassandra 
CASSANDRA_CONF=/etc/cassandra/conf 
CASSANDRA_INCLUDE=/usr/share/cassandra/cassandra.in.sh
EnvironmentFile=-/etc/default/cassandra
User=cassandra
PermissionsStartOnly=true
ExecStartPre=/usr/bin/install -m 755 -o cassandra -g cassandra -d 
/var/run/cassandra
ExecStart=/bin/sh -c '/usr/sbin/cassandra -p /var/run/cassandra/cassandra.pid > 
/var/log/cassandra/cassandra.log 2>&1'
Type=forking
PIDFile=/var/run/cassandra/cassandra.pid
TimeoutStopSec=25
SuccessExitStatus=0 143

[Install]
WantedBy=multi-user.target
{code}

I prefer the simpler unit. Thoughts?

> Stopping Cassandra shows status "failed" due to non-zero exit status
> --------------------------------------------------------------------
>
>                 Key: CASSANDRA-13436
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13436
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: Packaging
>            Reporter: Stefan Podkowinski
>
> Systemd will monitor the process from the pid file and save the return status 
> once if has been stopped. In case the process terminates with a status other 
> than zero, it will assume the process terminated abnormaly. Stopping 
> Cassandra using the cassandra script will send a kill signal to the JVM 
> causing it to terminate. If this happen, the JVM will exit with status 143, 
> no matter if shutdown hooks have been executed or not. In order to make 
> systemd recognize this as a normal exit code, the following should be added 
> to the yet to be created unit file:
> {noformat}
> [Service]
> ...
> SuccessExitStatus=0 143
> ...
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to