Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-10920

Let systemd know if Cassandra is running

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Not A Problem
    • None
    • Packaging

    Description

      Checking the status of the Cassandra service on CentOS 7 shows this:

      $ systemctl status cassandra
      ● cassandra.service - SYSV: Starts and stops Cassandra
         Loaded: loaded (/etc/rc.d/init.d/cassandra)
         Active: active (exited) since Fri 2015-12-18 13:30:02 CET; 3 days ago
           Docs: man:systemd-sysv-generator(8)
      ...
      

      The same is shown after the Cassandra process is killed or dies by itself. Notice this part: Active: active (exited)

      Starting Cassandra through systemctl start cassandra will not work, because systemd still thinks the service is running.

      According to the systemd documentation regarding compatibility with SysV this is expected behavior. Systemd doesn't know the PID of the Cassandra process and thus can't check if the service is running or not.

      It is suggested to add the following to the SysV script header comment:

      # pidfile: /var/run/cassandra/cassandra.pid
      

      After adding this manually systemd correctly detected the state of the Cassandra process on our machines.

      Update: /var/run/cassandra is missing after reboot

      Since CentOS 7 /var/run is a symlink to /run which is tmpfs-mounted. This makes /var/run/cassandra go away after a reboot and the PID file is never created again. (With the above change systemd even fails because it can't find the PID file.)

      I suggest adding this to make sure the directory for the PID file exists:

      start)
          # Cassandra startup
          echo -n "Starting Cassandra: "
      +   pid_dir=`dirname $pid_file`
      +   [ -d $pid_dir ] || install -m 755 -o $CASSANDRA_OWNR -d $pid_dir
          su $CASSANDRA_OWNR -c "$CASSANDRA_PROG -p $pid_file" > $log_file 2>&1
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            leonhardt Severin Leonhardt
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: