Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Server/Daemon startup issues when machine starts/reboots. Why ?




Dear All,
 
We have developed a sever ( basically a daemon) using Xcode 2.2 for Mac OS 10.4.x ppc/Intel and 10.3.9 which functionally performs well.
But I have some issues of server starting specifically when the machine starts/reboots and require your expert comments to resolve this tricky situation.
 
 
I have developed a script file that is used to start and stop the server. To start the sever automatically, we have included this script file in rc script (i.e. /etc/rc ). The server gets started automatically at start of the machine. 
 
But as per my requirements, the server needs to be connect to network and save some n/w relevant information in its database (e.g its own IP address) But unfortuntately, this does not happens, probably because the rc scripts makes run myserver "even before the network is initialized".  
A scenerio which makes me sure for this  is:
"Although my server gets started, but its database contains - 127.0.0.1 IP address instead of its original IP.
On the other hand if my restart my server when the machine is fully up, I get the correct n/w information. i.e. i get the correct IP 172.125.14.64 "
 
 
After going through some articles in Apple for starting/stopping the server ( http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/StartupItems.html ) I tried to load the server at startup so that the myserver should start only after the n/w is up. But unfortuantely, now my server doesnot even gets up at the startup.
 
I've put the following scriptfile inside a uniquely named folder in the /Library/StartupItems folder (which I also created) along with a simple StartupParameters.plist file.

However, it never seems to get loaded. That is, when I go into the Process Viewer, my server is never there. Neither do any of its (sparse) debug messages appear in the console. Below is the script file that I place in my folder.
 
. /etc/rc.common
StartService ()
{
 cd /Applications/MyCompany\ MyProduct/Common\ Files/MyProduct\ Keys\ Server
 sudo ./myServer
 ConsoleMessage "Starting myServer"
}

StopService ()
{
    sudo kill -9 $(ps -ax|grep ./myServer|head -n 1|cut -c 3-5)
 ConsoleMessage "Stopping myServer"
}

RestartService ()
{
    ConsoleMessage "Restarting myServer"
 sudo kill -9 $(ps -ax|grep ./myServer|head -n 1|cut -c 3-5)
 cd /Applications/MyCompany\ MyProduct/Common\ Files/MyProduct\ Keys\ Server
 sudo ./myServer
}

RunService "$1"

Did anybody faced similar situation ??? Can you please tell me where can be the possible issue ?? Why is the server not able to load at the startup ? All comments / suggestions are most welcome!


--
Rohit Dhamija(M) 9818446545
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.