nebula-plugins / gradle-ospackage-plugin

Gradle plugin for constructing linux packages, specifically RPM and DEBs.
Apache License 2.0
371 stars 129 forks source link

Supporting systemd as default for nebula.ospackage-daemon? #355

Open farrukhnajmi opened 4 years ago

farrukhnajmi commented 4 years ago

I tried out the nebula.ospackage to create a debian package for Ubuntu 18.04 server successfully and it rock! Thank you.

I then tried using nebula.ospackage-daemon plugin to extend my debian package to create a service for my app. I was not successful.

My daemon DSL looked like this:

daemon {
    daemonName = "${application.applicationName}"
    command = "env DISPLAY=:0 AD_PLAYER_APP_OPTS=\"-Dprism.verbose=true -DADPLAYER_DATA_FOLDER=/var/lib/${application.applicationName} --module-path=/opt/javafx-sdk-13.0.1/lib --add-modules=javafx.controls,javafx.swing,javafx.media,javafx.graphics\" /opt/${application.applicationName}/bin/${application.applicationName}"
    runLevels = [5]   // Multi-User Mode with Networking + display manager = [5]   // Multi-User Mode with Networking + display manager
    autoStart = true
    logDir = "/var/log/${application.applicationName}"

    // t: insert a tai64n timestamp (that can be translated to readable time with tai64nlocal)
    // s1048576: rotate the log file when it grows to 1MiB
    // n100: keep no more than 100 rotated files
    // /var/log/${application.applicationName}: The log directory to write logfiles to
    logCommand = "multilog t s1048576 n100 /var/log/${application.applicationName}"
}

The package installed fine and created files as expected under /service and /etc/init.d.

However, I could not get the service to start. It complained about an svc error:

Nov 06 18:13:59 ubuntu-factory my-app[714]: my-app: svc: warning: unable to control /service/my-app

This even though the /service/my-app file existed and had correct permissions.

Learning more about services in linux I learned that systemd is the new way to define services rather than init.d..

I was able to manually setup my app as a service using systemd easily following this resource and this resource.

I have two questions:

  1. What could explain why I got the svc error (I realize I may not be providing adequate info to answer this)
  2. What plans does the nebula.ospackage-daemon have to support systemd as the mechanism for its default templates
dhs-rec commented 2 years ago

Would also like to see native systemd services supported.

As for your first question: While Debian is Ubuntu's foundation, Ubuntu used its own upstart as init system, while Debian used sysv-init. That might explain your svc error.

However, having systemd supported would solve that problem, since ALL major distributions have switched to it completely.

DanielThomas commented 2 years ago

This is what we do currently for these:

https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/404#issuecomment-915698202