Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a Play 2.0 app on Debian?

I have play application, to make it easy to deploy on Debian, What are the ways to

  1. Create a daemon out of the code, with a standard init.d script, the main problem here how to gracefully stop the application?

  2. How can I compile the code as a fat jar, easy to maintain 1 single file compared to multiple files and directories (the standard way of deploying a Play app).

like image 703
sheki Avatar asked Mar 19 '12 13:03

sheki


1 Answers

  1. assuming you are using the "play dist" package, you could create a simple init.d script around it. Something like:

/etc/init.d/play.myplayapp

    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides:          play
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description:
    # Description:
    ### END INIT INFO

    APP="myplayapp"
    APP_PATH="/opt/play/$APP"

    start() {
        $APP_PATH/start &
    }

    stop() {
        kill `cat $APP_PATH/RUNNING_PID`
    }

    case "$1" in
      start)
        echo "Starting $APP"
        start
        echo "$APP started."
        ;;
      stop)
        echo "Stopping $APP"
        stop
        echo "$APP stopped."
        ;;
      restart)
        echo  "Restarting $APP."
        stop
        sleep 2
        start
        echo "$APP restarted."
        ;;
      *)
        N=/etc/init.d/play.$APP
        echo "Usage: $N {start|stop|restart}" >&2
        exit 1
        ;;
    esac

    exit 0

2. They don't really have a single file distribution of projects. The best you can do is running "play dist" to generate a distributable package. Even if it was distributed as a single file, it would probably be extracted to the file system at runtime just for efficiency (just how war files are handled).

like image 150
Kyrra Avatar answered Oct 07 '22 03:10

Kyrra