« »
9/02/2013

How to make Play Framework 2 work with Supervisord and Monit

Let say you just developed an application called myapp with Play Framework 2. The application is located in /dir/to/myapp
Before going further run play clean compile stage to build the app production jar, then configure supervisord and monit like so
[program:myplayapp]
; remove -Dconfig.file if necessary (play will use the default application.conf)
; change address and port if necessary or remove them to use the default values
command=java -Xms128M -Xmx512m -cp .:./lib/*:./target/staged/* -Dhttp.address=127.0.0.1 -Dhttp.port=9000 -Dconfig.file=./conf/application.prod.conf play.core.server.NettyServer .
: directory to the play framework app, where "myapp/" is the root
directory=/dir/to/myapp
process_name=myplayapp
autorestart=true
startsecs=10
stopwaitsecs=10
check process myapp
with pidfile /dir/to/myapp/RUNNING_PID
start program = "/usr/bin/supervisorctl start myplayapp"
stop program = "/usr/bin/supervisorctl stop myplayapp"
if 10 restarts within 20 cycles
then timeout
if TOTALMEMORY > 2 GB for 4 cycles then restart
view raw 2_monit.conf hosted with ❤ by GitHub
... et voila!

NB: Out of the box Play! will create a RUNNING_PID file into myapp/ but of course you can change its location with -Dpidfile.path.
« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.