0

I'm configuring a Java app to run at boot using jsvc, following this tutorial which uses systemv (init.d). I'm running Ubuntu 16.04, which uses systemd, and am having a hard time finding exactly what I need to do to have it run at boot, and stop at shutdown.

So far I know I need to create a service with Type=forking as the jsvc_exec command which starts/stops the app forks once it has run.

What else do I need to include to have it work in a similar way to the systemv script from the tutorial?

Thanks

1 Answer 1

1

Something like this:

 [Unit]
 Description=Description of daemon
 After=network.target

 [Service]
 #WorkingDirectory=/path/to/program/
 #User=
 #Group=
 Type=forking

 ExecStart=/path/to/program/program start
 ExecStop=/path/to/program/program stop
 #PIDFile=/path/to/pid/file.pid
 #RestartSec=15
 #Restart=always

[Install]
WantedBy=multi-user.target
8
  • This is exactly what I was looking for, thanks! One quick question, what is the PIDFile and where would I find it? Or does it not matter because the # comments the line?
    – Luke Moll
    Commented Sep 3, 2016 at 15:28
  • #comments the line, uncomment what you need
    – Alex
    Commented Sep 3, 2016 at 15:29
  • in the Arch wiki it said if it's specified systemd can keep track of the main process, if I wanted to include this where would I find the PID file?
    – Luke Moll
    Commented Sep 3, 2016 at 15:31
  • 1
    /var/run/mydaemon.pid I guess, from what I read in the tutorial...
    – Alex
    Commented Sep 3, 2016 at 15:33
  • 1
    Don't forget to sudo systemctl enable daemon.service where you replace daemon.service with the name of your service file, or it won't start at boot :)
    – Alex
    Commented Sep 3, 2016 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .