Start Me Up: Writing and Understanding OS X StartupItems
by Andrew Anderson10/21/2003
There's no denying that Mac OS X is popular among software developers and system administrators. These hard-core users are not the type of people generally associated with the Macintosh because they usually care more about features than user interfaces. What often lures them to OS X is the ease of both system administration and development tasks. On most platforms setting up programs and services that run during the startup process is often frustrating and confusing. Mac OS X, on the other hand, gives the developer or system administrator a precise and simple mechanism for handling the running of programs and services during the startup process.
In this article I will give an overview of how StartupItems fit into the OS X startup process, what you need to do to create a Startup Item, and provide an example of a StartupItem that will run the Apache project's Tomcat Java servlet engine. As you will see, StartupItems are easy to set up and extremely flexible in managing the startup process.
What are StartupItems?
|
Related Reading
Mac OS X: The Missing Manual, Panther Edition |
StartupItems, as their name implies, are programs that run during OS X's startup process. These programs can terminate after being run (think of emptying the trash on startup) or can be started and run in the background (like running the Apache web server). Though this may seem like a pretty simple service to provide, StartupItems offer several powerful features that differentiate them from similar features in OS X and similar mechanisms in other operating systems. The most powerful of these features are dependency ordering and dependency requirements.
Let's say that you are running both the Apache web server and the Tomcat servlet engine. Tomcat is set up so all of its requests are handled through Apache. In this situation you would want Tomcat to load after Apache is loaded and only if Apache is successfully loaded. Most operating systems would handle the startup process via a shell script. This script would contain code that runs Apache as well as code that runs Tomcat, possibly with some code in between that checks to make sure Apache is loaded properly before running Tomcat.
The script is easy enough to set up, but let's say your Tomcat process makes database calls to MySQL and you only want Tomcat to run if MySQL is loaded. Well, then your MySQL process depends upon an NFS-mounted disk, so you want to only run MySQL if NFS is loaded. This process is quite a bit more complicated, since writing the dependency conditions into a shell script would involve multiple, nested if statements. (If you do not think this example is complicated enough, think about adding IP services, which are required by Apache, MySQL, and Tomcat; Samba required by Apache; LDAP required by Tomcat; and Disk services required by all the other services.)
What does OS X do to get around the problem of writing a complex script? During the startup process OS X puts together a list of all the StartupItems that need to be run and orders this list based on the dependencies of each StartupItem. When a StartupItem is added or removed, no scripts need to be changed; OS X will automatically handle this the next time it starts up. In OS X creating a StartupItem involves creating an executable and a list of attributes, which include the dependencies. That's it, no scripts to write, edit, or test.
StartupItems versus LoginItems
OS X provides several mechanisms for running programs based on events in the login and startup process. Among these mechanisms are StartupItems, LoginItems, and shell startup scripts (used when you start up Terminal or X11). Each of these mechanisms is powerful in its own right, but they each have certain specific uses. The difference between LoginItems and StartupItems is probably the most confusing to those of us who use their Macs as single user machines.
Four major factors differentiate StartupItems from LoginItems. The first difference is the dependency ordering and requirements that we discussed in the last section. StartupItems have dependency ordering and LoginItems do not.
The other three factors that differentiate them are based on the individual processes that are run, specifically:
| StartupItems | LoginItems | |
| When is the the process run | during startup | after a user logs in |
| Who runs the process | by root, but not necessarily as root(more on this later) | the user |
| What types of processes can be run | background processes and processes that terminate after running | any Mac OS X executable |
The Apache StartupItem
Mac OS X looks in two places to build its list of StartupItems: /System/Library/StartupItems and /Library/StartupItems (/Library/StartupItems does not exist by default and you may need to create it). All StartupItems are treated equally when determining the order in which they are run, but /System/Library/StartupItems is reserved for StartupItems that come as part of OS X. The fact is, most of the default OS X StartupItems need to be run in advance of user-defined StartupItems, since the default OS X items provide basic services of the operating system, such as crash reporting, core graphics services, and system accounting.
One of the StartupItems that comes as part of OS X is Apache, the web server that OS X uses to provide personal web sharing and ftp services. /System/Library/StartupItems has a directory named Apache, which contains the files you'll need to make Apache run during the startup process. If you look in this directory you will notice two files: Apache and StartupParameters.plist and one directory: Resources. In this article, we will not be going over the Resources directory, but it contains the files necessary for language localization. (If you want to do language localization on a StartupItem, it is a straightforward process and looking into the Resources directory of any of the default OS X StartupItems will give you an excellent overview of how to proceed.) The two files, StartupParameters.plist and Apache provide the basis for the Apache StartupItem.
The Property List
StartupParameters.plist is a property list that contains the attributes that are used to run Apache. The property list should be at the root level of the subdirectory. This property list contains the following attributes:
{
Description = "Apache web server";
Provides = ("Web Server");
Requires = ("DirectoryServices");
Uses = ("Disks", "NFS", "Network Time");
OrderPreference = "None";
}
"Description" is a simple description of the service, which is only used to describe the file and not during the startup process.
"Provides" specifies the services that this StartupItems provides. Provides can contain multiple services, but it is not recommended. Here Apache provides a "Web Server" service.
"Requires" specifies the services that have to be started before this StartupItem is loaded. The values in this field are those of other StartupItems' "Provides" fields. Apache requires "DirectoryServices" to be loaded before it can be run; if DirectoryServices are not specified to run or fail to run properly Apache won't run.
"Uses" specifics the services that should be started before this StartupItem is loaded. This is similar to the "Requires" attribute except this service will always be loaded, but only after it has tried to execute all the services in "Uses". Apache uses the "Disks", "NFS", and "Network Time" services. OS X will try to load these services, if it can't it will still load Apache, but only after trying these services first.
"OrderPreference" specifies the general time period in which a StartupItem will be executed. This order is less significant than both "Requires" and "Uses" but is used to determine order after evaluating those attributes. The possible values for this attribute are: First, Early, None (default), Late, Last. Apache specifies no OrderPreference as to when it should be loaded.
The Executable File
The second file in this directory is named Apache and is the executable file that OS X will run during the startup process. The first thing to notice is that both the file and the directory are named Apache. The StartupItems specification requires that the executable file has the same name as the subdirectory that contains it and that the executable is in the root level of subdirectory.
Now it's time to take a look at the file:
#!/bin/sh
##
# Apache HTTP Server
##
. /etc/rc.common
StartService ()
{
if [ "${WEBSERVER:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting Apache web server"
apachectl start
fi
}
StopService ()
{
ConsoleMessage "Stopping Apache web server"
apachectl stop
}
RestartService ()
{
if [ "${WEBSERVER:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Restarting Apache web server"
apachectl restart
else
StopService
fi
}
RunService "$1"
The file starts like most shell scripts, by making sure the shell executes the script we want to run. After this, the script has a couple of lines of comments that tell us what the file does; in this instance it is the "Apache HTTP Server". The line after this loads the /etc/rc.common file. /etc/rc.common is a script library that Apple provides with useful routines for extracting parameters to scripts. One function that /etc/rc.common provides is RunService. When called with a single argument, RunService will run the function named "Argument"Service. For instance if you were to execute:
RunService "go";
it would execute the function named "GoService". The RunService function makes it easy to use command-line arguments to run different functions in a script, given different input arguments. If you look at the end of the Apache file, you will see the line:
RunService "$1"
"$1" specifies the first argument given to the script, so this command will execute a function based on the first argument to the script.
The executable that is used for a StartupItem needs to be able to accept a single argument that can take on one of three values: start, stop, or restart. This is to allow OS X to start the service during the startup process, stop the service during the shutdown process, or restart the service when specified (all of these can be done using the SystemStarter command in /sbin).
To support these three arguments there are three functions in the Apache file: StartService, StopService, and RestartService. These functions do exactly what their names imply: they start, stop, or restart the service that this executable defines. To create your own StartupItem executable all you need to do is replace the code in the StartService, StopService, and RestartService functions with code that will handle your program or service. (Of course, any program that accepts a single argument with the values start, stop, and restart can be a StartupItem. This method is by far the simplest way.)
You may also notice that all of the functions make a call to "ConsoleMessage". ConsoleMessage prints values to the OS X startup console. This "console" is the part of the screen that displays the messages that appear during the startup process.
Creating Your Own StartupItem
Now that we have seen what a StartupItem looks like, it is time to create your own. The first step is to create a directory that is named for the service you want to create. I would recommend creating this directory in your user account and you will copy the files into /Library/StartupItems when you have completed creating them. Since we are creating a StartupItem to start the Tomcat servlet engine, we will name our directory "Tomcat".
The next step is to create a property list file and our executable file. The easiest way to create these files is to copy them from the Apache StartupItem in /System/Library/StartupItems. Like so:
[ToadHall:~/projects/startupitems/Tomcat] mrtoad% cp /System/Library/StartupItems/Apache/Apache ./Tomcat
[ToadHall:~/projects/startupitems/Tomcat] mrtoad% cp /System/Library/StartupItems/Apache/StartupParameters.plist .
Once we have these files created we need to edit them so we can load Tomcat instead of Apache. We will start in StartupParameters.plist. The name of our service will be "Tomcat servlet engine"; it will provide "Servlet Engine" service, it will require "DirectoryServices"; it will use "NFS"; and it will have no order preference.
So the file should look like:
{
Description = "Tomcat servlet engine";
Provides = ("Servlet Engine");
Requires = ("DirectoryServices");
Uses = ("NFS");
OrderPreference = "None";
}
Next, we need to edit the executable file Tomcat. In this instance I am going to use Tomcat version 4.1, which on my machine is stored in /usr/local/jakarta-tomcat-4.1.18. This version of Tomcat has startup and shutdown scripts in its bin directory. The files are appropriately named: startup.sh and shutdown.sh. Both startup.sh and shutdown.sh require that the JAVA_HOME environment variable is set to the Java home directory on your machine. The default Java home directory in OS X is /Library/Java/Home.
When editing the file, we need to make five changes. First, we should change the comment at the beginning of the file specifying the name of the service. Next, we need to edit the three functions to use the Tomcat startup and shutdown scripts and finally, we need to set the JAVA_HOME environment variable before issuing the RunService function.
Our file should then look like this:
#!/bin/sh
##
# Tomcat Servlet Engine
##
. /etc/rc.common
StartService ()
{
ConsoleMessage "Starting Tomcat"
/usr/local/jakarta-tomcat-4.1.18/bin/startup.sh
}
StopService ()
{
ConsoleMessage "Stopping Tomcat"
/usr/local/jakarta-tomcat-4.1.18/bin/shutdown.sh
}
RestartService ()
{
ConsoleMessage "Restarting Tomcat"
/usr/local/jakarta-tomcat-4.1.18/bin/shutdown.sh
/usr/local/jakarta-tomcat-4.1.18/bin/startup.sh
}
JAVA_HOME=/Library/Java/Home; export JAVA_HOME
RunService "$1"
The final step is to copy the directory into /Library/StartupItems, like this:
[ToadHall:~/projects/startupitems] mrtoad% cp -r Tomcat /Library/StartupItems/
note: cp -r recursively copies the directory
Once the directory is copied, it is time to restart to test it out.
During the bootup process, depending on the speed of your machine, you should be able to see "Starting Tomcat" displayed on the console(if your machine is too fast, you might not catch it). Once OS X is booted, you can check to see if Tomcat is running by trying to load a JSP or servlet from your browser. If you use the standard Tomcat setup, you can test it at: http://localhost:8080/index.jsp.
The Finish Line
As you can see, StartupItems are a powerful yet simple framework for managing the startup process. Once you get through the background information and understand what is going on, StartupItems are easy to both set up and use.
Andrew Anderson is a software developer and consultant in Chicago who's been using and programming on the Mac as long as he can remember.
Return to the Mac DevCenter
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 30 of 30.
-
Security problem
2009-10-15 11:35:28 Darlan [Reply | View]
Hi, i need run a application when the mac is starting, i have do some tests but nothing works.
can you help me?
First i created a folder called MyStartupItem on directory /Library/StartupItems/
After this i created my shell script like in a tutorial that i found on the web.
_______________________________________________________________
#!/bin/sh
. /etc/rc.common
# start subroutine
StartService() {
# Insert your start command below. For example:
ConsoleMessage "opening chess"
open /Applications/Chess.app
# End example.
}
StopService() {
# Insert your stop command(s) below. For example:
#killall -TERM mydaemon
#sleep 10
# killall -9 mydaemon
# End example.
}
# The restart subroutine
RestartService() {
# Insert your start command below. For example:
#killall -HUP mydaemon
# End example.
}
RunService "$1"
_______________________________________________________________
I created too a StartupParameters.plist in the same folder that i had created before, but i don't understand how configure it.
_______________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Description</key>
<string>Chess</string>
<key>OrderPreference</key>
<string>None</string>
<key>Provides</key>
<array>
<string>Chess</string>
</array>
<key>Uses</key>
<array>
<string>None</string>
<string>Resolver</string>
</array>
</dict>
</plist>
_______________________________________________________________
when i reboot my mac, show a message saying that my script don't have the security setting, but the button "FIX" doesn't appear like i saw in some sites.
what i'm doing wrong?
thanks, darlan
-
OS 10.5 Instructions
2008-08-19 19:27:38 dklanac [Reply | View]
Hi everyone,
I went through the article instructions and found that they may be out of date. I am brand new, so I am posting a very similar solution that worked for me after reviewing a MySQL startup script. I am running a personal license of Atlassian Confluence which uses Tomcat.
1. StartupItems.plist should be renamed to StartupParameters.plist
2. StartupParameters.plist should make use of an XML schema rather than the YAML version posted (am I correct in my assumption?)
My StartupParameters.plist file:
<plist version="1.0">
<dict>
<key>Description</key>
<string>Confluence Wiki</string>
<key>OrderPreference</key>
<string>None</string>
<key>Provides</key>
<array>
<string>Confluence</string>
</array>
<key>Requires</key>
<array>
<string>DirectoryServices</string>
</array>
<key>Uses</key>
<array>
<string>NFS</string>
</array>
</dict>
</plist>
4. Test using /sbin/SystemStarter start Confluence. I noticed that Console still outputs the "unknown service" message, but it appears that it can be safely ignored in my case.
5. Make use of the same Tomcat script with the correct Tomcat startup.sh path.
6. Restart your system, and you should be able to access your Tomcat servlet location. In my case, it was the default http://localhost:8080/
Cheers,
David
-
Unknown service?
2008-05-21 19:07:47 ackhoo [Reply | View]
I have created my own StartupItems under /Library/StartupItems, to perform some mounting each time when my Mac Mini reboots. I have followed the steps recommended in this article.
1. create a new folder called “ace_executor” under /Library/StartupItems
2. put ace_executor.sh under /Library/StartupItems/ace_executor
3. put StartupParameters.plist under /Library/StartupItems/ace_executor
4. create Resoruces/English.lproj folder under /Library/StartupItems/ace_executor and put the file Localizable.strings in it
5. change permissions of /Library/StartupItems to 755
6. reboot my Mac Mini
When I rebooted my machine, I notice that it didn't run my startup item. I got this from Console Message:
May 21 10:16:48 pg-sw-mac3 SystemStarter[16]: "/Library/StartupItems/ace_executor" failed sanity check: path was created after boot up
I then manually run: sudo /sbin/SystemStarter -d start /Library/StartupItems/ace_executor. This time, it said that:
May 21 10:16:48 pg-sw-mac3 SystemStarter[139]: Found item: ace_executor
May 21 10:16:48 pg-sw-mac3 SystemStarter[139]: Unknown service: ace_executor
The above message leads me to think we need to register the ace_executor service somewhere?
Any clue? Please advice.
Thanks
Ai Choo
-
difference between /System/Library/StartupItems and /Library/StartupItems
2008-01-30 23:01:29 nick.armstrong [Reply | View]
Can someone please explain the difference between these two directories in terms of what gets executed when?
Thanks.
-
Startup works for one user only?
2006-11-30 00:17:06 BFido [Reply | View]
Hi, i´m using startupitem to run synergy (which allows me to access several computers with one keyboad). For the user that logins first it woks fine, but when I swich to another user, the connection is gone. Has someone any idea to solve the problem?
Thanks
Tomek
-
Add static route startupitems
2006-06-28 10:31:30 tibu [Reply | View]
Hi everybody,
I tried to add a static route in the Startupitems, I create a folder Addroute and a script Addroute in this folder and the file StartupParameters.plist but doesnt work!
Can you give the code to put in the file script Addroute please! THANKS
-
StartupItems troubleshooting
2006-04-25 14:19:37 iamstein [Reply | View]
Hello,
I have created a custom firewall, based on the instructions from the Firewall column. If I type the following after logging in:
sudo -s /Library/StartupItems/Firewall/Firewall start
Everything runs just fine. However, Firewall is not running on startup, or if it is, there is an error. Can you give me some ideas on how to address this issue? Thanks,
Andy
-
Testing with SystemStarter 10.3.9
2006-03-07 05:14:16 GhostyDog [Reply | View]
Hi
Took me a while to figure this out and I don't know if it's just my machine but I had to give SystemStarter the name I stated in the 'provides' part of the property list for testing. Like this.
# sudo SystemStarter stop "Servlet Engine"
If I stated Tomcat then SystemStarter told me it could find no Service with that name.
Hope this helps anybody who has the same problem.
GD
-
You don't have to restart your maschine...
2005-07-22 05:51:32 Leona.Eden [Reply | View]
just open your favorite console and type (as root):<br/>
<br/>
/sbin/SystemStarter start Tomcat
and your done. If Tomcat ist already running then you can userestartinstead.
-
Didn't work with SSL
2005-01-12 20:07:09 sammyD [Reply | View]
StartupItem works for me on port 8080, however, https://localhost:8443 did not work. When I start Tomcat manually, not with StartupItem, connection on port 8443 works fine. What am I missing?
-
Tomcat Startup on Panther 10.3.2
2004-03-15 03:18:36 wkanoff@cablespeed.com [Reply | View]
I tried the script, replacing the my file structure for the one shown and restarted the machine. Tomcat did not start. I went to the terminal and typed in /Library/Tomcat/bin/startup.sh and Tomcat started. Any idea what is wrong.
Tomcat is in /Library/Tomcat. -
Tomcat Startup on Panther 10.3.2
2004-03-15 03:34:37 Andrew Anderson | [Reply | View]
Problem is it is in the wrong directory, as the article says, it should be in:
/Library/StartupItems/Tomcat
-
Running a StartupItem as a different user?
2003-12-23 14:59:03 anonymous2 [Reply | View]
The article promises to explain how to run a StartupItem as someone other than root but I must have missed it. Is there something built in other than running your start, stop and restart commands as "sudo -u otheruser mycommand"?
-
/Library/StartupItems and Fink's init.sh
2003-12-20 12:13:24 anonymous2 [Reply | View]
printenv > somelogfile.log shows that the startup items are run in a minimalistic environment -- after rc.common is loaded, only PATH, SHLVL, and _ are defined! The problem is, this means that the if [ -z "$FOO" ] etc. clauses in fink's init.sh will fail when variable FOO isn't already defined, and so using apache2 or popfile (which I have configured to use BerkeleyDB from fink) means starting them by hand.
The solution was to copy /sw/bin/init.sh to /etc/initfink.sh (or whatever), trim down the various variable-defining conditionals in initfink.sh (such as if [ -z "$MANPATH"] ... fi) with the knowledge that $PATH exists and the rest don't, replacing them with the appropriate consequence or alternative. Then, adding ". /etc/initfink.sh" after pulling in rc.common makes everything work.
-
StartupItems may soon be moot
2003-11-11 21:02:37 anonymous2 [Reply | View]
Apple is phasing out the StartupItems mechanism for loading daemons and services and moving to a "load-on-demand" approach that uses a tool called register_mach_bootstrap_servers. Here's the document that gives the details:
System startup: The Boot Process (Bootstrap Daemons section)
http://developer.apple.com/documentation/macosx/Conceptual/BPSystemStartup/Concepts/BootProcess.html#//apple_ref/doc/uid/20002130/CJBBICAB
-
StartupItems may soon be moot
2005-03-08 18:28:05 ylon [Reply | View]
From the looks of it StartupItems will probably not be going away too soon, plus I've read:
"The documentation fails to mention this, but this facility is for Mach Servers only, and there is no replacement for SystemStarter available."
from http://www.opendarwin.org/pipermail/darwinports/2003-December/018926.html
Now whether that is still true, I know not.
-
RunService
2003-10-24 16:01:40 anonymous2 [Reply | View]
A minor nit.. but I don't believe the following statement is quite correct:
"When called with a single argument, RunService will run the function named "Argument"Service. For instance if you were to execute:
RunService "go";
it would execute the function named "GoService". "
If you look at the RunService function found in /etc/rc.common you'll find that it's actually a case statement that specifically looks for the arguments "start", "stop" or "restart" and then calls "StartService", "StopService" or "RestartService" respectively. Any other parameter will be treated as an unknown argument.
So you can't arbitrarily set up any function name (say "FooService") in your startup script and expect
RunService "Foo"
to call it.
Steve -
"RunService" not available on Mac OS 10.1
2004-02-04 14:21:06 smithkennedy [Reply | View]
I would also like to add that the "RunService" shell script function is not implemented in rc.common on Mac OS 10.1.x, so if you do need to support that version of Mac OS X, you should keep this in mind. You can do a test to see if RunService is in /etc/rc.common, and switch on that, like so:
FOUND_RUN_SERVICE=`grep -c RunService /etc/rc.common`
if [ ${FOUND_RUN_SERVICE} -a ${FOUND_RUN_SERVICE} -eq 1 ]; then
RunService $1
else
StartService
fi
Also, make sure your property list file is the old NeXT-style instead of the newer XML .plist file format(s). SystemStarter will crash if it hits one of these newer .plist files.
-
RunService
2003-10-24 16:16:47 Andrew Anderson | [Reply | View]
My mistake, thanks for pointing that out. I took the word of some documentation and didn't bother to read rc.common.
Andrew
-
Privileges
2003-10-22 09:21:21 anonymous2 [Reply | View]
And please don't forget to set privileges properly. When set incorrectly (e.g. world writable, or group writable witht he wrong group) anyone could use your script to gain root access to the system at system startup. For istance by modifying your script to set the suid bit on a file of one choosing.
Ernst Mulder
-
Stop
2003-10-21 18:02:30 anonymous2 [Reply | View]
So have they actually added support for running these things at shutdown yet, or is this still unimplemented? -
Stop
2003-10-23 08:38:37 anonymous2 [Reply | 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 12:35:53 anonymous2 [Reply | 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 | [Reply | 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
2003-10-23 08:52:00 Andrew Anderson | [Reply | 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-22 07:29:22 anonymous2 [Reply | 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 [Reply | 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 [Reply | 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.






can you help me?
First i created a folder called MyStartupItem on directory /Library/StartupItems/
After this i created my shell script like in a tutorial that i found on the web.
_______________________________________________________________
#!/bin/sh
. /etc/rc.common
# start subroutine
StartService() {
# Insert your start command below. For example:
ConsoleMessage "opening chess"
open /Applications/Chess.app
# End example.
}
StopService() {
# Insert your stop command(s) below. For example:
#killall -TERM mydaemon
#sleep 10
# killall -9 mydaemon
# End example.
}
# The restart subroutine
RestartService() {
# Insert your start command below. For example:
#killall -HUP mydaemon
# End example.
}
RunService "$1"
_______________________________________________________________
I created too a StartupParameters.plist in the same folder that i had created before, but i don't understand how configure it.
_______________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Description</key>
<string>Chess</string>
<key>OrderPreference</key>
<string>None</string>
<key>Provides</key>
<array>
<string>Chess</string>
</array>
<key>Uses</key>
<array>
<string>None</string>
<string>Resolver</string>
</array>
</dict>
</plist>
_______________________________________________________________
when i reboot my mac, show a message saying that my script don't have the security setting, but the button "FIX" doesn't appear like i saw in some sites.
what i'm doing wrong?
thanks, darlan