简体   繁体   中英

How to run the Play's dist file in the background?

When I deployed my play application I built the package using:

dist

This created a file that I can run on my server like:

sudo ./bin/app-name -Dhttp.port=9090

This works fine for testing but how can I run this process in the background?

I will eventually have to use upstart or some sort of process monitoring tool to make sure this process is running after server reboots etc.

Using play 2.3.x

Since you are on ubuntu

sudo ./bin/app-name -Dhttp.port=9090 & 

should do the trick.

Ceating the upstart script is also fairly easy https://askubuntu.com/questions/18802/how-to-correctly-add-a-custom-daemon-to-init-d In your case it would be in /etc/init/app-name.conf and look like

# app-name
#   

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec $PATH_TO_APP/bin/app-name -Dhttp.port=9090

Of course you will want to change the RUNLEVEL and the PATH_TO_APP

That of course depends on the system at which you're deploying the app, anyway in general you need to run it as a deamon.

Refer to your system's documentations, I'm pretty sure that you will find tutorial very soon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM