Project

foreground

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Control daemonizing background processes with launchd.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.4.11
>= 0.5.1
>= 0
>= 0.9.0

Runtime

~> 1.2.2
 Project Readme

foreground

Control daemonizing background processes with launchd.

Introduction

Some processes do unspeakable things, which makes it hard for launchd to control them:

A daemon or agent launched by launchd MUST NOT do the following in the process directly launched by launchd:

  • Call daemon(3).
  • Do the moral equivalent of daemon(3) by calling fork(2) and have the parent process exit(3) or _exit(2).

-- launchd.plist(5)

This tiny wrapper makes sure, that those processes are properly started or stopped on behalf of launchd by mirroring the job's running state.

Installation

Install it via RubyGems:

$ gem install foreground

Usage

Wrap your daemon command inside your launchd.plist:

foreground --pid_file /tmp/foreground_sample_daemon.pid --command "foreground_sample_daemon --with arguments"

Limitations

You can't control the daemons stdout, stderr, etc. this way, because the daemon will probably manage this stuff itself.

Contributing

  1. Fork it and script/bootstrap your environment (Note: This also performs a hard git reset to restore bin/foreground_sample_daemon, which gets overwritten by bundler!)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2012 Björn Albers (MIT License)