Warning: Use of undefined constant Flash_Clock_Widget_widget - assumed 'Flash_Clock_Widget_widget' (this will throw an Error in a future version of PHP) in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/flash-clock-widget/flash-clock-widget.php on line 132

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/fs/package.module.fs.php on line 258

Warning: preg_match(): Compilation failed: invalid range in character class at offset 31 in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/router/package.module.router.php on line 465

Warning: preg_match(): Compilation failed: invalid range in character class at offset 30 in /home/dolgov/blog.outdev.ru/docs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/router/package.module.router.php on line 465
Outsource Development » Launching background processes at startup

Launching background processes at startup

Posted on March 9th, 2010 by AVD

The preferred way of launching background processes in Mac OS X means using launchd by creating LaunchDaemons and LaunchAgents which are simple plist (Property List) files which instruct launchd how to start or stop these processes. The important difference in the two is that LaunchDaemons are intended for processes which should remain running even with no users logged into the system.

The common property list format is:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
  <key>Disabled</key>
  <false/>
  <key>Label</key>
  <string>program ID</string>
  <key>OnDemand</key>
  <false/>
  <key>Program</key>
  <string>program executable path</string>
  <key>ProgramArguments</key>
  <array>
    <string>program executable path</string>
    <string>program parameter #1</string>
    <string>program parameter #2</string>
    <string></string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

For example, to launch svnserve replace bold text with following:

program ID:
  org.tigris.Subversion

program executable path:
  /usr/bin/svnserve (or your custom path)

program parameters (each in separate line enclosed with ‘string’ tag):
  -d
  –root=path to root
  –log-file=path to log file

Save resulting file at path “/Library/LaunchDaemons/org.tigris.Subversion.plist”.

We’re now ready to make sure it will work. If you’ve got the svnserve daemon running, open up the Activity Monitor and locate the svnserve process. Select it and press the Quit Process button in the Activity Monitor toolbar. You should be asked for your administrator password. When the process exits it will disappear from the list.

After the process has closed, switch to the Terminal. We’re ready to test our LaunchDaemon to start it up again. In the Terminal, type the following:

sudo launchctl load /Library/LaunchDaemons/org.tigris.Subversion.plist

Enter your administrator password. You should be returned to a new prompt in the shell if everything goes well.

To verify that our process is registered with launchd, we can print out a list of all the processes run with launchctl by running:

sudo launchctl list

You should see the org.tigris.Subversion item in the list. You can further test that the LaunchDaemon works by simply restarting your system and again checking the Activity Monitor to verify that the svnserve process is running.

Categories: General


Warning: count(): Parameter must be an array or an object that implements Countable in /home/dolgov/blog.outdev.ru/docs/wp-includes/class-wp-comment-query.php on line 405