Start Me Up: Writing and Understanding OS X StartupItems
Subject:   Stop
Date:   2003-10-21 18:02:30
From:   anonymous2
So have they actually added support for running these things at shutdown yet, or is this still unimplemented?
Full Threads Newest First

Showing messages 1 through 8 of 8.

  • Stop
    2003-10-22 07:29:22  anonymous2 [View]

    No, Apple still hasn't figured out how to send Stop and Restart messages. Hopefully they will figure it out in Panther. Interesting, though, SystemStarter can be told to send Stop and Restart messages to the services and this works very well. I think you can pull up a man page on SystemStarter to see how to use it.
    • Stop
      2003-10-22 09:41:22  anonymous2 [View]

      That is too bad. I have looked into this before as well and I am surprised that they have not done this. How are you supposed to run things like databases that need to be cleanly shutdown on OS X Server? To me this is a critical feature in production server environments and one that Apple will have to address to be considered when replacing Linux servers. I have read the section in the OS X System manual on StartupItems when it came out and am excited to see how it works in practice. I would be ok with them making it a setting and documenting known issues with the OS calling the stop parameter on shutdown. At least we would have a workaround then. Is anyone else conserned about running production databases on OS X Server without having the ability to shut them down cleanly?
      • Stop
        2003-10-28 05:00:05  anonymous2 [View]

        Personally, I've found that servers need to be (deliberately) shutdown so rarely that it isn't a hassle to shutdown the relevant processes manually before telling the machine to reboot.
        If it goes down for some other reason (lightning, blackouts, people tripping over power cords... none of which should happen to properly set up servers) then the shutdown scripts wouldn't be called anyway.
        It's a convenience thing, but it's not really a necessity when it's used fair less frequently than many other useful features of Mac OS X.
  • Stop
    2003-10-23 08:38:37  anonymous2 [View]

    Why would you have to specifically shutdown one item?
    I'm no expert but I think that a shutdown in unix kills all running processes. That would include the Tomcat server, Apache, MySql etc.
    It would be kind of redundant to write a specific shutdown item when shutting down the system.
    • Stop
      2003-10-23 08:52:00  Andrew Anderson | [View]

      Killing a process is not the best way to stop a process because it does not take into account the processes state.

      For instance:
      I have mysql running and I am in the midst of an insert, OS X (or the user) kills the process, does the data get inserted correctly ? What part of the insert did it stop in the middle of ? Did half of the insert work ?

      Same can happen in Apache or Tomcat. Think a php script or Java class that writes an external file or goes to a database.

      Shutdown procedures allow the program to clean up after itself before stopping, wait for a database connection to cease or else cease it, explicitly close or wait for files to close, etc.
    • Stop
      2003-10-23 12:35:53  anonymous2 [View]

      Killing a process isn't enough for many types of servers - it can result in data loss, or worse. Without support for shutdown items, OS X is still not suitable for use as a server OS. This is the most glaring omission in an otherwise fine OS, and is a show-stopper for serious use.
      • Stop
        2003-10-23 13:55:29  Andrew Anderson | [View]

        Saying that "OS X is still not suitable for use as a server OS" is a bit of an overstatement.

        If you write a script that does:

        1.) stop all services that were started as StartupServices, ie/ run 'SystemStarter stop'

        2.) stop all services that were started outside of StartupServices (like something that was put manually into rc )

        3.) if you are allowing remote ssh logins, warn users that the machine is shutting down with "write"

        Run the script as root and then do the shutdown. Or write an AppleScript that does the shutdown for you and add that to the script.
  • Stop
    2006-12-04 08:00:13  gordguide [View]

    A service has a Start and Stop functions. Stop function is executed upon shutdown. You can leave the start function unused if you like so that it functions solely as a shutdown service.

    If you need a "nice" (ie orderly) shutdown, script it (shell, applescript, automator workflow, or any combination).


    . /etc/rc.common

    StartService ()
    # what to do on boot (can be empty)

    StopService ()
    # what to do on shutdown (can be empty)

    RunService "$1"

    This file has to be executable, i.e. chmod a+x filename. Then create a file by the name StartupParameters.plist with the following contents:

    Description = "Name of your service goes here";
    Provides = ("Whatever your service provides goes here");
    Uses = ("Disks");