[Unit]
Description=Play1 app
After=network.target
[Service]
Type=forking
PIDFile=/path/to/app/server.pid
ExecStartPre=/bin/sh -c 'cd /path/to/app ;/bin/rm server.pid
ExecStart=/path/to/app/bin/play -Dhttp.port=9000 -J-server // This is what it looks like in Play2
ExecStop=/bin/kill $MAINPID
ExecStopPost=/bin/rm /path/to/app/server.pid
ExecRestart=/bin/kill $MAINPID
Restart=true
[Install]
WantedBy=multi-user.targetHi Johan,
Not sure about how to use Play1 apps as I never used 1.x.
ExecStart= should have the command you would start by launching the app yourself, without considering service.
However, if the parent process of the command never ends when the app is started, you may not want to use Type=forking.
From systemd man:
If set to forking, it is expected
that the process configured with ExecStart=
will call fork() as part of its
start-up. The parent process is expected to exit when start-up is
complete [..].
If the main process of the app never ends, you may prefer Type=simple.
You can take a look at https://www.freedesktop.org/software/systemd/man/systemd.service.html and see the different options about the type of service and the ones related to pid file.
If you cannot manage to start the app, please join some infos
about the problem, inputs, journal logs or the observed behaviour.
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/13f06b94-afea-41db-9071-449ec4c00766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
VERSION="1.4.4"PLAY_LOC="/usr/local/share"PLAY_PATH="${PLAY_LOC}/play-${VERSION}"PLAY_COMMAND="${PLAY_PATH}/play"
if [ ! -f $PLAY_COMMAND ] ;then PLAY_ARCH="${PLAY_LOC}/play-${VERSION}.zip"; wget -O $PLAY_ARCH $PLAY_URL; unzip $PLAY_ARCH -d $PLAY_LOC ;fi
$PLAY_COMMAND stop . --%mania2
killall java
$PLAY_COMMAND clean .
$PLAY_COMMAND start . -Xms2048M -Xmx4096M --%mania2VERSION="1.4.4"PLAY_LOC="/usr/local/share"PLAY_PATH="${PLAY_LOC}/play-${VERSION}"PLAY_COMMAND="${PLAY_PATH}/play"
if [ ! -f $PLAY_COMMAND ] ;then PLAY_ARCH="${PLAY_LOC}/play-${VERSION}.zip"; wget -O $PLAY_ARCH $PLAY_URL; unzip $PLAY_ARCH -d $PLAY_LOC ;fi
$PLAY_COMMAND stop . --%mania2
killall java
$PLAY_COMMAND clean .
rm server.pid
git pull origin mania
$PLAY_COMMAND deps .
$PLAY_COMMAND start . -Xms4096M -Xmx4096M --%mania2
VERSION="1.4.4"PLAY_LOC="/usr/local/share"PLAY_PATH="${PLAY_LOC}/play-${VERSION}"NOW=$(date +"%m-%Y")LOG_FILE="./system-$NOW.log"PLAY_COMMAND="${PLAY_PATH}/play"
if [ ! -f $PLAY_COMMAND ] ;then PLAY_ARCH="${PLAY_LOC}/play-${VERSION}.zip"; wget -O $PLAY_ARCH $PLAY_URL; unzip $PLAY_ARCH -d $PLAY_LOC ;fi
$PLAY_COMMAND stop . --%mania2
killall java
Unfortunately I didn't have time to use another script for checking play and import it in all of them... Just write another script like checkPlay.sh and import it at the top, so no more redundancy...
VERSION="1.4.4"PLAY_LOC="/usr/local/share"PLAY_PATH="${PLAY_LOC}/play-${VERSION}"PLAY_COMMAND="${PLAY_PATH}/play"
if [ ! -f $PLAY_COMMAND ] ;then PLAY_ARCH="${PLAY_LOC}/play-${VERSION}.zip"; wget -O $PLAY_ARCH $PLAY_URL; unzip $PLAY_ARCH -d $PLAY_LOC ;fi
if [ -f $PLAY_COMMAND ] ;then echo 'play is good to go';fi
[Unit]
Description=runs pokermania
[Service]
Type=forking
RemainAfterExit=yes
WorkingDirectory=/var/www/playApp
ExecStart=/bin/sh -c 'ulimit -n 655350 ; cd /var/www/playApp ; ./update.sh'
#ExecStop=/bin/sh -c 'cd /var/www/playApp && ./stop.sh'
[Install]
WantedBy=multi-user.target
env PLAY_BINARY=<path to play>
env HOME=<path to app>
env USER=playuser
env GROUP=users
env PROFILE=prod
env NEW_RELIC=/home/playuser/newrelic/newrelic.jar
start on (filesystem and net-device-up IFACE=lo) or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 022
expect fork
pre-start script
test -x $PLAY_BINARY || { stop; exit 0; }
test -c /dev/null || { stop; exit 0; }
chdir ${HOME}
rm ${HOME}/server.pid || true
# $PLAY_BINARY dependencies $HOME
end script
pre-stop script
exec $PLAY_BINARY stop $HOME
end script
post-stop script
rm ${HOME}/server.pid || true
end script
script
exec start-stop-daemon --start --exec $PLAY_BINARY --chuid $USER:$GROUP -- start $HOME -Dprecompiled=true --%$PROFILE --http.port=9001 -javaagent:$NEW_RELIC
end script[Unit]
Description=<app description>
After=network.target
[Service]
Type=forking
PIDFile=<pid file location>
ExecStartPre=/bin/sh -c 'cd <path to app> ;/bin/rm server.pid
ExecStart=/bin/sh -c '<play path>/play start <path to app> -Dprecompiled=true --%qa --http.port=9001 -javaagent:/home/playuser/newrelic/newrelic.jar'
ExecStop=/bin/kill $MAINPID
ExecStopPost=/bin/rm <path to app>/server.pid
ExecRestart=/bin/kill $MAINPID
Restart=on-failure
User=playuser
Group=playuser
[Install]
WantedBy=multi-user.target