Changeset 14481 for trunk/base


Ignore:
Timestamp:
Oct 8, 2005, 7:01:54 PM (19 years ago)
Author:
jberry
Message:
  • Declare global destroot-keepdirs when we use it
  • Sync more flexibility in pidfile specification back up to launchd support
  • Cleanup some comments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portstartupitem.tcl

    r14480 r14481  
    22# portstartupitem.tcl
    33#
    4 # $Id: portstartupitem.tcl,v 1.15 2005/10/08 18:42:21 jberry Exp $
     4# $Id: portstartupitem.tcl,v 1.16 2005/10/08 19:01:54 jberry Exp $
    55#
    66# Copyright (c) 2004, 2005 Markus W. Weissman <mww@opendarwin.org>,
     
    4343#
    4444#       startupitem.pidfile             none
    45 #               - There is no pidfile we can track
     45#               There is no pidfile we can track
    4646#
    4747#       startupitem.pidfile             auto [filename.pid]
    4848#               The daemon is responsible for creating/deleting the pidfile
    49 #               - We can use this to try to detect if the process is already running
    50 #               - We can use this to try to ensure that the process has stopped
    5149#
    5250#       startupitem.pidfile             cleanup [filename.pid]
    5351#               The daemon creates the pidfile, but we must delete it
    54 #               - We can use this to try to detect if the process is already running
    5552#
    5653#       startupitem.pidfile             manual [filename.pid]
     
    5956#       startupitem.logfile             logpath
    6057#               Log to the specified file -- if not specified then output to /dev/null
    61 #               - for launchd, just set this as the key
     58#               - for launchd, just set this as the standard out key
    6259#               - for systemstarter, redirect to this
    6360#
     
    6562#               Log events to the log
    6663#               - for launchd, generate log messages inside daemondo
    67 #               - for systemstarter, generate log messages in script
     64#               - for systemstarter, generate log messages in our generated script
    6865#
    6966
     
    120117
    121118proc startupitem_create_darwin_systemstarter {args} {
    122         global prefix destroot portname os.platform
     119        global prefix destroot destroot.keepdirs  portname os.platform
    123120        global startupitem.name startupitem.requires startupitem.init
    124         global startupitem.start startupitem.stop startupitem.restart
    125         global startupitem.executable
     121        global startupitem.start startupitem.stop startupitem.restart startupitem.executable
    126122        global startupitem.pidfile startupitem.logfile startupitem.logevents
    127123       
     
    186182        if { ![llength ${startupitem.requires} ] } {
    187183                set startupitem.requires [list Disks NFS]
     184        }
     185        if { ![llength ${startupitem.logfile} ] } {
     186                set startupitem.logfile "/dev/null"
    188187        }
    189188       
     
    372371
    373372proc startupitem_create_darwin_launchd {args} {
    374         global prefix destroot portname os.platform
     373        global prefix destroot destroot.keepdirs portname os.platform
    375374        global startupitem.name startupitem.requires startupitem.init
    376         global startupitem.start startupitem.stop startupitem.restart
    377         global startupitem.executable
     375        global startupitem.start startupitem.stop startupitem.restart startupitem.executable
    378376        global startupitem.pidfile startupitem.logfile startupitem.logevents
    379377
     
    497495        # If pidfile was specified, translate it for daemondo.
    498496        #
    499         # There are three cases:
    500         #       (1) auto pidfilename
    501         #       (2) cleanup pidfilename
    502         #       (3) manual pidfilename
     497        # There are four cases:
     498        #       (1) none
     499        #       (2) auto [pidfilename]
     500        #       (3) cleanup [pidfilename]
     501        #       (4) manual [pidfilename]
    503502        #
    504503        set pidfileArgCnt [llength ${startupitem.pidfile}]
    505         if { ${pidfileArgCnt} } {
     504        if { ${pidfileArgCnt} > 0 } {
     505                if { $pidfileArgCnt == 1 } {
     506                        set pidFile "${prefix}/var/run/${itemname}.pid"
     507                        lappend destroot.keepdirs "${destroot}${prefix}/var/run"
     508                } else {
     509                        set pidFile [lindex ${startupitem.pidfile} 1]
     510                }
     511
    506512                if { ${pidfileArgCnt} != 2 } {
    507513                        ui_error "$UI_PREFIX [msgcat::mc "Invalid parameter count to startupitem.pidfile: 2 expected, %d found" ${pidfileArgCnt}]"
    508                 } else {
    509                         # Translate into appropriate arguments to daemondo
    510                         set pidStyle [lindex ${startupitem.pidfile} 0]
    511                         set pidPath      [lindex ${startupitem.pidfile} 1]
    512                         switch ${pidStyle} {
    513                                 auto    { lappend args "--pid=fileauto" "--pidfile" ${pidPath} }
    514                                 clean   { lappend args "--pid=fileclean" "--pidfile" ${pidPath} }
    515                                 manual  { lappend args "--pid=exec" "--pidfile" ${pidPath} }
    516                                 default {
    517                                         ui_error "$UI_PREFIX [msgcat::mc "Unknown pidfile style %s presented to startupitem.pidfile" ${pidStyle}]"
    518                                 }
     514                }
     515               
     516                # Translate into appropriate arguments to daemondo
     517                set pidStyle [lindex ${startupitem.pidfile} 0]
     518                switch ${pidStyle} {
     519                        none    { lappend args "--pid=none" }
     520                        auto    { lappend args "--pid=fileauto" "--pidfile" ${pidFile} }
     521                        clean   { lappend args "--pid=fileclean" "--pidfile" ${pidFile} }
     522                        manual  { lappend args "--pid=exec" "--pidfile" ${pidFile} }
     523                        default {
     524                                ui_error "$UI_PREFIX [msgcat::mc "Unknown pidfile style %s presented to startupitem.pidfile" ${pidStyle}]"
    519525                        }
    520526                }
Note: See TracChangeset for help on using the changeset viewer.