Play Framework Start Script for RHEL 7

Play Framework Start Script for RHEL 7

I modified these play framework start scripts to replace our original init.d scripts that we used to use for our Play Framework Scala applications. The original scripts were always a bit flaky on us, and well, never really worked 100%. I decided it was time to redo the init.d scripts.

In the end, I decided to use sbt-publish plugins to create RPM packages that we could install and would have the init.d built in. This unit.d worked well for the most part, but had to be modified to accommodate app configurations. Most of my new app builds use this new sbt-publish approach, but some of our older bigger apps don’t. I decided I would just rip the init.d that was created from the sbt-publish process and use that as a starting place. Lots of credit goes to the sbt-release crew for this init.d starting point.

My approach allows for the use of the /etc/init.d/play_framework_appname file, and the use of/etc/default/play_framework_appname, as well as /etc/sysconfig/play_framework_appname use cases.

I prefer to do this so I can move all of the configuration items out of the init.d file, and keep them in the sysconfig or default files. I can also lock down those files with permissions like 700 so that only root (and sudo etc) can see any secret keys inside.

So in this we have two files that I created.

  1. /etc/init.d/play_framework_appname
  2. /etc/default/play_framework_appname

/etc/init.d/play_framework_appname

That is it for the init.d. To make things simple just do a FIND and REPLACE of ‘play_framework_appname’ and insert your appname.

/etc/default/play_framework_appname

Notice the permissions are locked down to only root. This is because we store all the secret connection settings and passwords here, and not in the code itself.

 

This script assumes a few things.

  1. You app is located in /usr/local/play_framework_appname/current
  2. The executable is located in the /usr/local/play_framework_appname/current/bin/ folder and is named play_framework_appname.
  3. you are loading the production.conf file. (rename this to application.conf or whatever .conf file you want loaded.)

That’s it for today folks.

Have questions? Concerns? Did I make a mistake again? (Very likely) Then please leave a comment.