I have heard that Ubuntu upstart is the way to go for dameonization. So I tried this:
First I added an init script in /etc/init/application.conf:
description "Application"
author "David Williams"
env JAVA_OPTS="-server -verbose:gc -Xms1G -Xmx4G -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC"
respawn
exec su nobody -s /bin/sh -c 'exec /usr/java/default/bin/java -jar /home/ec2-user/Application.one-jar.jar'
But then this fails:
$ start application
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.123" (uid=500 pid=8161 comm="start)
interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply=0
destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init))
If I remember correctly I also need a file in /etc/init.d but I am finding the Upstart docs to be kindof opaque since I'm also not a sysadmin. What should I do to get this running like an upstart script?
$ start application
$ stop application
$ restart application
[UPDATE]
I needed to use sudo
$ sudo start application
application start/running, process 8399
But that process doesnt list under ps aux
$ sudo ps aux | grep 8339
ec2-user 8424 0.0 0.0 103244 820 pts/0 S+ 19:41 0:00 grep 8339
Stuck here.