# scylla-server - ScyllaDB
#
# ScyllaDB

description	"ScyllaDB server"

start on runlevel [2345]
stop on runlevel [!2345]

umask 022

console log

expect stop
respawn
# allow ample time to flush the commit log on large memory / slow disk systems
kill timeout 3600
normal exit 0 1 2
setuid scylla
setgid scylla
limit core unlimited unlimited
limit memlock unlimited unlimited
limit nofile 800000 800000
limit as unlimited unlimited
limit nproc 8096 8096
chdir /var/lib/scylla
env HOME=/var/lib/scylla

pre-start script
    if [ "$AMI" = "yes" ]; then
        sudo /usr/lib/scylla/scylla-ami/scylla_ami_setup
    fi
    sudo /usr/lib/scylla/scylla_prepare
end script

script
    . /etc/default/scylla-server
    for i in /etc/scylla.d/*.conf; do
        if [ "$i" = "/etc/scylla.d/*.conf" ]; then
            break
        fi
        . "$i"
    done
    export SCYLLA_CONF SCYLLA_HOME
    exec /usr/bin/scylla $SCYLLA_ARGS $SEASTAR_IO $DEV_MODE $CPUSET
end script

post-stop script
    sudo /usr/lib/scylla/scylla_stop
end script
