Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#44295 closed enhancement (fixed)

support more than one launchd plist

Reported by: cro (C. R. Oldham) Owned by: jmroot (Joshua Root)
Priority: Normal Milestone: MacPorts 2.5.0
Component: base Version: 2.3.1
Keywords: Cc: ctreleaven (Craig Treleaven)
Port:

Description

Greetings,

I am updating the Portfile for Salt. I'm trying to add two variants--"master" and "minion". The default is "minion". Both variants have a startupitem, but at the end of the install (port install salt +master +minion) I get

--->  Fetching distfiles for salt
--->  Verifying checksums for salt
--->  Extracting salt
--->  Configuring salt
--->  Building salt
--->  Staging salt into destroot
--->  Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting salt with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load salt
###########################################################\

but my Portfile says

[...]
default_variants    +minion

variant minion {
    startupitem.create        yes
    startupitem.name          salt-minion
    startupitem.netchange     yes
    startupitem.logevents     yes
    startupitem.logfile       ${prefix}/var/log/salt/minion
    startupitem.executable    ${prefix}/bin/salt-minion

    if ![file exists /opt/local/etc/salt/minion] {
        file copy ${worksrcpath}/conf/minion /opt/local/etc/salt
    }
}

variant master {
    startupitem.create        yes
    startupitem.name          salt-master
    startupitem.netchange     yes
    startupitem.logevents     yes
    startupitem.logfile       ${prefix}/var/log/salt/master
    startupitem.executable    ${prefix}/bin/salt-master
[...]

and 'port load salt' returns

port load salt
Error: org.macports.load for port salt returned: Launchd plist /Library/LaunchDaemons/org.macports.salt-minion.plist was not found

and indeed only org.macports.salt-master.plist is present in /Library/LaunchDaemons.

So can I not put startup item directives in a variant?

Change History (6)

comment:1 Changed 7 years ago by ryandesign (Ryan Schmidt)

Component: portsbase
Port: salt removed
Priority: HighNormal
Summary: Attempting to add more than one LaunchItemsupport more than one launchd plist
Type: requestenhancement

Yes, you can put startupitem directives in variants. However, it is usually best not to do so because "port load" and "port unload" would not work seamlessly, and furthermore, MacPorts base does not currently have the capability for creating more than one launchd plist in a single port. Of course you can manually create any file and copy it where it needs to go.

However, consider whether master and minion might best be implemented as subports.

comment:2 in reply to:  1 Changed 7 years ago by cro (C. R. Oldham)

Replying to ryandesign@…:

However, consider whether master and minion might best be implemented as subports.

That sounds good, is there documentation on how subport works? I tried replacing 'variant minion' with 'subport salt-minion' but that doesn't seem to generate the desired result.

comment:3 Changed 3 years ago by ctreleaven (Craig Treleaven)

Cc: ctreleaven added

comment:4 Changed 3 years ago by neverpanic (Clemens Lang)

Owner: changed from macports-tickets@… to jmroot
Status: newassigned

Joshua said he has an approach in mind for this ticket in https://lists.macports.org/pipermail/macports-dev/2018-February/037329.html. Joshua, please consider whether you want to fix this for 2.5.0, and set the milestone if so.

comment:5 Changed 3 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: assignedclosed

In 99d5fb30eb4c1ba8b7924807a052291ba31b792c/macports-base:

Allow multiple startupitems per port

The portfile interface is a new option called 'startupitems'. This
should be filled with a list of key/value pairs, with the names of the
keys corresponding to the startupitem.* options. Each startupitem
declared this way must speficy at least a name. Other options will be
taken to have the value of the corresponding startupitem.* option if
not present. Options apply to the name that appeared immediately prior.

Example:

startupitem.create yes
startupitems name mydaemon \

executable ${prefix}/bin/mydaemon \
name anotherthing \
start "${prefix}/bin/another --someflag"
stop "${prefix}/bin/another shutdown"

Fixes: #44295

comment:6 Changed 3 years ago by jmroot (Joshua Root)

Milestone: MacPorts 2.5.0
Note: See TracTickets for help on using tickets.