Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpm java_server archetype - systemV init scripts #149

Closed
muuki88 opened this issue Feb 2, 2014 · 15 comments
Closed

rpm java_server archetype - systemV init scripts #149

muuki88 opened this issue Feb 2, 2014 · 15 comments

Comments

@muuki88
Copy link
Contributor

muuki88 commented Feb 2, 2014

The autostart feature is currently only tested on debian systems. Systems using rpm (fedora, centOS, RHEL) are not included yet.

  • Find the according start up mechanisms
  • Implement a separation for different scripts (debian, rpm)

Some links found on the research for this ticket

@muuki88 muuki88 assigned muuki88 and unassigned muuki88 Feb 11, 2014
@muuki88
Copy link
Contributor Author

muuki88 commented Feb 13, 2014

I started with this, but got stuck. This is my init.d script:

#!/bin/sh
#
# mukis-test <mukis-test>
#
# chkconfig: - 20 80
# description: Mukis Test Daemon
#

### BEGIN INIT INFO
# Provides: mukis-test
# Required-Start: 
# Required-Stop: 
# Should-Start: 
# Should-Stop: 
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mukis Test Daemon
# Description: Mukis Test Daemon Long
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

prog="mukis-test"
config="/vagrant/mukis-test.conf"

PIDFILE=/var/run/mukis-test.pid

if [ -z "$DAEMON_USER" ]; then
    #DAEMON_USER=${{daemon_user}}
    DAEMON_USER=vagrant
fi


# smb could define some additional options in $RUN_OPTS
#RUN_CMD="${{chdir}}/bin/${{app_name}}"
RUN_CMD="/vagrant/mukis-test.sh"

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    # if not running, start it up here, usually something like "daemon $exec"
    daemon --user $DAEMON_USER --pidfile $PIDFILE $RUN_CMD
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    # stop it here, often "killproc $prog"
    # TODO this is SO BRUTAL!
    killproc -p $PIDFILE #$RUN_CMD
    retval=$?
    echo "Returning $retval"
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?

95% are copied from the Fedora template.

The script which should get started looks like this:

#!/bin/bash
touch /tmp/mukis-test
ping localhost >> /tmp/mukis-test &

System is CentOS 6.5

Problems

  • When I remove the & in the startscript, then the daemon() call never returns
  • With the & the daemon gets started, but I can't stop it. I don't really get what the status() method does

@timperrett
Copy link

@jsuereth - when might we be able to get rpm packaging for server supported? I'd really love to have this so we dont have to use debian. Thanks for the awesome work, cheers

@muuki88
Copy link
Contributor Author

muuki88 commented Feb 26, 2014

Hi @timperrett
This currently my top-1 priority, but didn't have time for anything else last week. Hopefully I get this done until the end of next week. The startscript is really the big stopper right now. So if you have any hints :)

@muuki88
Copy link
Contributor Author

muuki88 commented Feb 27, 2014

I just found out that CentOS 6 uses Upstart

@timperrett
Copy link

Really? Damn. That would be convenient for this issue right!!

@aparkinson
Copy link
Contributor

Upstart might not be around for much longer as Debian are going to SystemD and Ubuntu will be following suite. Most RPM distro's have already gone SystemD for there latest versions

@muuki88 I now have time to put towards this issue

@muuki88
Copy link
Contributor Author

muuki88 commented Feb 28, 2014

Yeah, I read about SystemD. This will be the next major version :D
I'll provide a pull request for this ticket in a few minutes (hopefully) with a first draft

@jsuereth
Copy link
Member

SystemD? Man. What am I going to do with all my ubuntu services now?

@muuki88
Copy link
Contributor Author

muuki88 commented Feb 28, 2014

At first glance the config files look rather similiar. So for a first draft it shouldn't be toooooo hard :P
However if all major linux distributions switch to one system start system, I'm more than happy.

@timperrett
Copy link

Oh cool, good stuff guys! Is there a snapshot or milestone build with this? I can give it a whirl :-)

@muuki88
Copy link
Contributor Author

muuki88 commented Mar 1, 2014

Currently no snapshot or milestone (we should think about a snapshot @jsuereth , @aparkinson ?)
However you can do the following

git clone git@github.com:sbt/sbt-native-packager.git
cd sbt-native-packager
sbt
set scalaVersion in Global := "2.10.3"
set sbtVersion in Global := "0.13.1"
publish-local

Then copy the version (looks like 0.6.3-<git-sha>), which appears a lot in the build log and insert it to your plugin.sbt.

@ytask
Copy link

ytask commented Mar 1, 2014

Hi, I would also be very interested to give it a try. By the way, really great work guys regarding the native-packager.

@timperrett
Copy link

Ok so i just tried master. It works... super awesome. When can we get a milestone release? :-D @jsuereth or @muuki88 really hoping you guys can help me out!

Love your work

@muuki88
Copy link
Contributor Author

muuki88 commented Mar 12, 2014

We'll plan to ship a release candidate very soon (hopefully the next days). So hang tight :) #191

@muuki88
Copy link
Contributor Author

muuki88 commented Mar 12, 2014

0.7.0-RC1 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants