0

in order to be able to start my application at boot time i have followed the Upstart instruction.

I have create a file /etc/init/poolparty.conf, within which i have defined the following:

# poolparty - poolparty job file

# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Essentially lets upstart know the process will detach itself to the background
expect fork

# Run before process
pre-start script
    [ -d /var/run/poolparty ] || mkdir -p /var/run/poolparty
    echo "starting Poolparty"
end script

# Start the process
exec /opt/poolparty/bin/poolparty start

This is an application that needs the network started, the multi-usermode started. In any case, whatever the machine needs to start first need to be there. It can be started at the end of the boot process.

However when i reboot, nothing happens.

What else do i need to do to start it ? Can someone help ?

When i type service poolparty start, i either get that the service is already started or nothing. In any case it does not work i checked it.

So if any one could guide me here that would be great. I would like to check the log as well.

Btw /opt/poolparty/bin/poolparty is an executable script, that set things and call a java application. It uses jsvc64 to start a java application based on Tomcat.

muru
  • 197,895
  • 55
  • 485
  • 740

1 Answers1

1

As you are saying it require network and you are creating new directory so it need local-filesystem also .so you have to use

start on (local-filesystems and net-device-up IFACE!=lo)

or

start on (local-filesystem and started networking)

instead of

start on runlevel [2345]

and you can try

if [ ! -e /var/run/poolparty ]; then
     /bin/mkdir  /var/run/poolparty
   fi

instead of

  [ -d /var/run/poolparty ] || mkdir -p /var/run/poolparty
        echo "starting Poolparty"

suggestion : see upstart log under /var/log/upstart that will help you where you are missing. and also check syntax error of init script using command:

init-checkconf -d /etc/init/poolparty.conf  

and for better understanding of upstart script see Upstart Ubuntu cookbook

pl_rock
  • 11,297
  • Thank you for the answer. The command needs to be run as root does it matter ? (/opt/poolparty/bin/poolparty start) – MaatDeamon Oct 06 '15 at 05:59
  • i don't think so. most of init script run as root . refer http://askubuntu.com/questions/297992/how-do-i-run-a-script-on-startup-as-superuser – pl_rock Oct 06 '15 at 06:13
  • Yes actually i made it work with " start on (local-filesystems and net-device-up IFACE!=lo)" . Maybe what you try to write that is referred in the doc is "start on started network-services". I could not find in the doc "start on (local-filesystem and started networking)" – MaatDeamon Oct 06 '15 at 07:13
  • In any case i have no specific requirements at the init of the machine. I just need everything to be up and start the Service. – MaatDeamon Oct 06 '15 at 07:13
  • I also had to provide a Java_Home, as the service is a java application. – MaatDeamon Oct 06 '15 at 07:18
  • One last comment i did not need "if [ ! -e /var/run/poolparty ]; then /bin/mkdir /var/run/poolparty fi" actually !! I don't really know why an application would need something external to set this folder. In any case it failed at the check. I had a syntax error with it – MaatDeamon Oct 06 '15 at 07:19
  • i thought you trying to create directory if not exist see http://stackoverflow.com/a/31585484 . it is working . is you problem solve ? – pl_rock Oct 06 '15 at 07:26