This Play's doc already describes using of Apache for 'transparent upgrading'. In general you need to start two instances in two separate folders
At the beginning:
- Create
dist
package inside your folder with apps sources
- Unzip it to some subfolder ie.
instance1
- Start
instance1
on desired port for an example 9998
it will be your every-day instance
After changes, when you want to redeploy app transpalently:
- Push changes to server (assuming that you are using some versioning system, ie. git)
- Create
dist
and unzip it to other folder ie. instance2
- Start it on the other port ie.
9999
- Stop application in folder
instance1
- Copy unzipped dist from
instance2
to instance1
- Start application in
instance1
and stop application on instance2
- Repeat this procedure every time you need to redeploy with new changes.
Of course creating simple shell script which will perform all steps at once will be great helper for you.
TIP:
To avoid often re-deployment, especially when you need just to replace/modify some public and static contents like CSS or images, you can also use Apache common vhost
for handling these resources. Just create a vhost
for some folder as a subdomain ie. http://static.domain.tld
or better with separate domain: http://my-cdn.tld
so you can use a path like:
<img src="http://static.domain.tld/images/photo.png" alt="" />
instead of
<img src="/public/images/photo.png" alt="" />
The benefits:
- You don't need to redeoploy the app to change these files.
- You don't send the cookies, which are mostly redundant for public assets (if vhost's domain is other than main project)
- You can use HTTP server's configuration for setting cache tags (performance!)
- You are sharing statics automatically between all instances.
- You don't waste JVM resources for serving the pictures :) I noticed that, although Play's default server can be really fast, serving static contents with simple HTTP server is probably faster...
And finally, from my experience, nginx is faster than Apache. So if only task for HTTP server in your case is load-balancing the Play's apps, consider using nginx it's just lighter.