Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed problem in Cassandra init script #134

Merged
merged 1 commit into from

4 participants

Theo Hultberg Josh Kalderimis Michael Klishin αλεx π
Theo Hultberg

Updated the Cassandra init script so that the cassandra service starts properly and shuts down cleanly.

I believe this should fix travis-ci/travis-ci#840

The current script repeats most of what's in /usr/local/cassandra/bin/cassandra, but not enough, there's a lot of the environment Cassandra needs to start that is missing. This patch changes it so that it simply runs cassandra -p $PIDFILE and daemonizes it with start-stop-daemon (by way of start_daemon). The stop and status tasks had to change too.

The script still contains some hard coded paths and some interpolated, if you pass in another conf_dir or even installation_dir it will no longer work. I can fix that too if you'd like but I though that just fixing the issue at hand was best to start with. There's also some stuff that could be removed now when /usr/local/cassandra/bin/cassandra is doing most of the lifting (the part that finds JAVA_HOME for example).

Theo Hultberg iconara Fixed problem in Cassandra init script
Updated the Cassandra init script so that the `cassandra` service starts properly and shuts down cleanly.

The current script repeats most of what's in `/usr/local/cassandra/bin/cassandra`, but not enough, there's a lot of the environment Cassandra needs to start that is missing. This patch changes it so that it simply runs `cassandra -p $PIDFILE` and daemonizes it with `start-stop-daemon` (by way of `start_daemon`). The stop and status tasks had to change too.
dbcc1b0
Josh Kalderimis
Owner

Hey @iconara

Wow, thank you, I had one question, do you think it is worth changing to use the official cassandra deb? (http://wiki.apache.org/cassandra/DebianPackaging)

I have had reports that the deb installs a correct init script.

Thanks a bundle,

Josh

Michael Klishin

Debian packages also try to tweak system parameters that fail on OpenVZ (because OpenVZ does not allow them to be modified).

Michael Klishin michaelklishin merged commit 04c2a16 into from
Michael Klishin

@iconara thank you. I hope there will be another PR to this repo ;)

Josh Kalderimis
Owner
Theo Hultberg

@joshk unfortunately haven't tried the deb myself, so I don't know.

@michaelklishin PR coming up.

αλεx π

Thanks for the fix! It seems that I ran into the same problem.

Just wondering, when these changes could become available on Travis itself?

Theo Hultberg iconara referenced this pull request in michaelklishin/cassandra-chef-cookbook
Merged

Fixed problem in the init script #4

Theo Hultberg

Thanks for merging this. I'll work with @michaelklishin to create an updated Cassandra recipe with the other changes I mentioned.

Theo Hultberg iconara deleted the branch
Josh Kalderimis
Owner

I have updated the JVM workers with these changes and it produces some odd results.

https://next.travis-ci.org/simong/cassandratravis

It looks like all the log output is going to STDOUT and it is quite verbose.

@iconara are you able to look into this further?

Theo Hultberg

That's a bit odd, but I know what's going on. I didn't redirect STDOUT when cassandra is started, but I thought service would take care of that and not output it into the test runner output. I'll fix it.

Josh Kalderimis
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2013
  1. Theo Hultberg

    Fixed problem in Cassandra init script

    iconara authored
    Updated the Cassandra init script so that the `cassandra` service starts properly and shuts down cleanly.
    
    The current script repeats most of what's in `/usr/local/cassandra/bin/cassandra`, but not enough, there's a lot of the environment Cassandra needs to start that is missing. This patch changes it so that it simply runs `cassandra -p $PIDFILE` and daemonizes it with `start-stop-daemon` (by way of `start_daemon`). The stop and status tasks had to change too.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 20 deletions.
  1. +7 −20 ci_environment/cassandra/templates/default/cassandra.init.erb
27 ci_environment/cassandra/templates/default/cassandra.init.erb
View
@@ -105,7 +105,7 @@ classpath()
# process is not running but the pidfile exists (to match the exit codes for
# the "status" command; see LSB core spec 3.1, section 20.2)
#
-CMD_PATT="-user.cassandra.+CassandraDaemon"
+CMD_PATT="cassandra.+CassandraDaemon"
is_running()
{
if [ -f $PIDFILE ]; then
@@ -130,23 +130,9 @@ do_start()
ulimit -l unlimited
ulimit -n "$FD_LIMIT"
- cp=`classpath`
- cassandra_home=`getent passwd cassandra | awk -F ':' '{ print $6; }'`
- cd / # jsvc doesn't chdir() for us
-
- # echo "Classpath is $cp"
- $JSVC \
- -user cassandra \
- -home $JAVA_HOME \
- -pidfile $PIDFILE \
- -errfile "&1" \
- -outfile /var/log/$NAME/output.log \
- -cp $cp \
- -Dlog4j.configuration=log4j-server.properties \
- -XX:HeapDumpPath="$cassandra_home/java_`date +%s`.hprof" \
- -XX:ErrorFile="$cassandra_home/hs_err_`date +%s`.log" \
- $JVM_OPTS \
- org.apache.cassandra.thrift.CassandraDaemon
+ cd /
+
+ start_daemon -p $PIDFILE $CASSANDRA_HOME/bin/cassandra -p $PIDFILE
is_running && return 0
for tries in `seq $WAIT_FOR_START`; do
@@ -167,8 +153,9 @@ do_stop()
# 2 if daemon could not be stopped
# other if a failure occurred
is_running || return 1
- $JSVC -stop -home $JAVA_HOME -pidfile $PIDFILE \
- org.apache.cassandra.thrift.CassandraDaemon
+
+ killproc -p $PID
+
is_running && return 2 || return 0
}
Something went wrong with that request. Please try again.