https://github.com/thuehlinger/daemons
Ruby daemons gem official repository
https://github.com/thuehlinger/daemons
Keywords from Contributors
activerecord activejob mvc rubygem feature-flag crash-reporting rack rspec feature-toggle feature
Last synced: about 21 hours ago
JSON representation
Repository metadata
Ruby daemons gem official repository
- Host: GitHub
- URL: https://github.com/thuehlinger/daemons
- Owner: thuehlinger
- License: mit
- Created: 2014-04-12T07:38:33.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2025-11-24T08:04:51.000Z (3 months ago)
- Last Synced: 2026-02-27T08:15:58.336Z (4 days ago)
- Language: Ruby
- Size: 544 KB
- Stars: 645
- Watchers: 5
- Forks: 71
- Open Issues: 26
- Releases: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
Ruby Daemons
Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server)
to be run as a daemon and to be controlled by simple start/stop/restart commands.
If you want, you can also use daemons to run blocks of ruby code in a daemon process and to control
these processes from the main application.
Besides this basic functionality, daemons offers many advanced features like exception backtracing
and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes
if they crash.
Basic Usage
You can use Daemons in four different ways:
1. Create wrapper scripts for your server scripts or applications
Layout: suppose you have your self-written server myserver.rb:
# this is myserver.rb
# it does nothing really useful at the moment
loop do
sleep(5)
end
To use myserver.rb in a production environment, you need to be able to
run myserver.rb in the background (this means detach it from the console, fork it
in the background, release all directories and file descriptors).
Just create myserver_control.rb like this:
# this is myserver_control.rb
require 'daemons'
Daemons.run('myserver.rb')
And use it like this from the console:
$ ruby myserver_control.rb start
(myserver.rb is now running in the background)
$ ruby myserver_control.rb restart
(...)
$ ruby myserver_control.rb stop
For testing purposes you can even run myserver.rb without forking in the background:
$ ruby myserver_control.rb run
An additional nice feature of Daemons is that you can pass additional arguments to the script that
should be daemonized by seperating them by two hyphens:
$ ruby myserver_control.rb start -- --file=anyfile --a_switch another_argument
2. Create wrapper scripts that include your server procs
Layout: suppose you have some code you want to run in the background and control that background process
from a script:
# this is your code
# it does nothing really useful at the moment
loop do
sleep(5)
end
To run this code as a daemon create myproc_control.rb like this and include your code:
# this is myproc_control.rb
require 'daemons'
Daemons.run_proc('myproc.rb') do
loop do
sleep(5)
end
end
And use it like this from the console:
$ ruby myproc_control.rb start
(myproc.rb is now running in the background)
$ ruby myproc_control.rb restart
(...)
$ ruby myproc_control.rb stop
For testing purposes you can even run myproc.rb without forking in the background:
$ ruby myproc_control.rb run
3. Control a bunch of daemons from another application
Layout: you have an application my_app.rb that wants to run a bunch of
server tasks as daemon processes.
# this is my_app.rb
require 'daemons'
task1 = Daemons.call(:multiple => true) do
# first server task
loop do
conn = accept_conn()
serve(conn)
end
end
task2 = Daemons.call do
# second server task
loop do
something_different()
end
end
# the parent process continues to run
# we can even control our tasks, for example stop them
task1.stop
task2.stop
exit
4. Daemonize the currently running process
Layout: you have an application my_daemon.rb that wants to run as a daemon
(but without the ability to be controlled by daemons via start/stop commands)
# this is my_daemons.rb
require 'daemons'
# Initialize the app while we're not a daemon
init()
# Become a daemon
Daemons.daemonize
# The server loop
loop do
conn = accept_conn()
serve(conn)
end
For further documentation, refer to the module documentation of Daemons.
Displaying daemon status
When daemonizing a process using a wrapper script, as examples 1 and 2 above,
the status can be shown using
$ ruby myproc_control.rb status
By default this will display whether or not the daemon is running and, if it
is, its PID.
A custom message can be shown with
def custom_show_status(app)
# Display the default status information
app.default_show_status
puts
puts "PS information"
system("ps -p #{app.pid.pid.to_s}")
puts
puts "Size of log files"
system("du -hs /path/to/logs")
end
Daemons.run('myserver.rb', { show_status_callback: :custom_show_status })
Documentation
Documentation can be found at http://www.rubydoc.info/gems/daemons.
Author
Written 2005-2021 by Thomas Uehlinger, 2014-2016 by Aaron Stone.
Owner metadata
- Name: Thomas Uehlinger
- Login: thuehlinger
- Email:
- Kind: user
- Description:
- Website:
- Location: Zurich
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1449958?u=677d79facc89e0cb2d941243c64c7d0298a40763&v=4
- Repositories: 5
- Last ynced at: 2023-08-27T11:53:31.262Z
- Profile URL: https://github.com/thuehlinger
GitHub Events
Total
- Watch event: 3
- Pull request event: 1
- Fork event: 1
- Create event: 1
Last Year
- Watch event: 2
- Pull request event: 1
- Fork event: 1
- Create event: 1
Committers metadata
Last synced: 3 days ago
Total Commits: 183
Total Committers: 29
Avg Commits per committer: 6.31
Development Distribution Score (DDS): 0.563
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Thomas Uehlinger | t****r@g****m | 80 |
| Adam Cuppy | a****m@c****m | 43 |
| Aaron Stone | a****n@s****x | 19 |
| Peter Goldstein | p****n@g****m | 4 |
| Ryan Lue | h****o@r****m | 4 |
| Denys Matveev | s****3@g****m | 3 |
| Paul Gallagher | g****l@g****m | 3 |
| dingoEgret | s****t@g****m | 2 |
| Andreas Bomholtz | a****s@s****m | 2 |
| Ivan Nečas | i****s@r****m | 2 |
| Tobias Thiel | t****1@g****m | 2 |
| dependabot[bot] | 4****] | 2 |
| Willian Gustavo Veiga | w****a | 1 |
| Joe Haig | j****g@b****k | 1 |
| Philipp Großelfinger | p****r@a****e | 1 |
| paul | p****l@c****m | 1 |
| roberto.plancarte | r****e@o****m | 1 |
| W. Andrew Loe III | a****w@a****m | 1 |
| Ryuta Kamizono | k****o@g****m | 1 |
| Robert Schulze | r****t@d****e | 1 |
| Philipp | p****g@p****m | 1 |
| Olle Jonsson | o****n@g****m | 1 |
| Lukas Zapletal | l****t@r****m | 1 |
| Luis M Rodriguez-R | l****r@g****m | 1 |
| Kazuki Nishikawa | k****a@g****m | 1 |
| Graham Rogers | g****m@o****m | 1 |
| Daniel Sinn | d****n@p****m | 1 |
| Christian Schmidt | cs@f****k | 1 |
| Akira Matsuda | r****e@d****p | 1 |
Committer domains:
- redhat.com: 2
- dio.jp: 1
- firmafon.dk: 1
- pagerduty.com: 1
- ophelos.com: 1
- pictrs.com: 1
- dotless.de: 1
- andrewloe.com: 1
- oracle.com: 1
- callrail.com: 1
- arri.de: 1
- bbc.co.uk: 1
- seluxit.com: 1
- ryanlue.com: 1
- serendipity.cx: 1
- codingzeal.com: 1
Issue and Pull Request metadata
Last synced: 2 months ago
Total issues: 50
Total pull requests: 45
Average time to close issues: 2 months
Average time to close pull requests: 26 days
Total issue authors: 44
Total pull request authors: 29
Average comments per issue: 2.64
Average comments per pull request: 1.29
Merged pull request: 39
Bot issues: 0
Bot pull requests: 5
Past year issues: 0
Past year pull requests: 3
Past year average time to close issues: N/A
Past year average time to close pull requests: 3 months
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 0.33
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 3
Top Issue Authors
- thuehlinger (7)
- scooler (1)
- Paxa (1)
- parhs (1)
- bwinter (1)
- dideler (1)
- floodico (1)
- tboyko (1)
- hrenfroe (1)
- utkarshrai003 (1)
- robertoplancarte (1)
- lmrodriguezr (1)
- sada (1)
- trombik (1)
- boncey (1)
Top Pull Request Authors
- sodabrew (8)
- dependabot[bot] (5)
- petergoldstein (3)
- SephVelut (2)
- intentionaccident (2)
- tardate (2)
- iNecas (1)
- TastyPi (1)
- rlue (1)
- AndreasBomholtz (1)
- acuppy (1)
- dsinn (1)
- phigrofi (1)
- tobithiel (1)
- amatsuda (1)
Top Issue Labels
- bug (5)
- question (3)
- enhancement (2)
- help wanted (1)
Top Pull Request Labels
- dependencies (5)
- github_actions (3)
Package metadata
- Total packages: 9
-
Total downloads:
- rubygems: 613,997,994 total
- Total docker downloads: 1,332,136,978
- Total dependent packages: 455 (may contain duplicates)
- Total dependent repositories: 77,190 (may contain duplicates)
- Total versions: 93
- Total maintainers: 1
gem.coop: daemons
Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.
- Homepage: https://github.com/thuehlinger/daemons
- Documentation: http://www.rubydoc.info/gems/daemons/
- Licenses: MIT
- Latest release: 1.4.1 (published over 4 years ago)
- Last Synced: 2026-02-28T11:31:55.748Z (3 days ago)
- Versions: 38
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 306,988,910 Total
- Docker Downloads: 666,068,489
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.025%
- Downloads: 0.074%
- Maintainers (1)
rubygems.org: daemons
Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.
- Homepage: https://github.com/thuehlinger/daemons
- Documentation: http://www.rubydoc.info/gems/daemons/
- Licenses: MIT
- Latest release: 1.4.1 (published over 4 years ago)
- Last Synced: 2026-03-01T07:02:46.073Z (3 days ago)
- Versions: 38
- Dependent Packages: 455
- Dependent Repositories: 77,190
- Downloads: 307,009,084 Total
- Docker Downloads: 666,068,489
-
Rankings:
- Downloads: 0.072%
- Dependent packages count: 0.1%
- Dependent repos count: 0.133%
- Docker downloads count: 0.584%
- Average: 1.048%
- Stargazers count: 2.28%
- Forks count: 3.12%
- Maintainers (1)
proxy.golang.org: github.com/thuehlinger/daemons
- Homepage:
- Documentation: https://pkg.go.dev/github.com/thuehlinger/daemons#section-documentation
- Licenses: mit
- Latest release: v1.4.1 (published over 4 years ago)
- Last Synced: 2026-02-27T22:02:04.607Z (4 days ago)
- Versions: 11
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 2.434%
- Forks count: 2.987%
- Average: 6.44%
- Dependent packages count: 9.56%
- Dependent repos count: 10.779%
ubuntu-23.04: ruby-daemons
- Homepage: https://github.com/thuehlinger/daemons
- Licenses: mit
- Latest release: 1.4.1-1 (published 21 days ago)
- Last Synced: 2026-02-11T06:37:41.105Z (21 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.10: ruby-daemons
- Homepage: https://github.com/thuehlinger/daemons
- Licenses: mit
- Latest release: 1.4.1-1 (published 18 days ago)
- Last Synced: 2026-02-13T18:17:45.604Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-daemons
- Homepage: https://github.com/thuehlinger/daemons
- Documentation: https://packages.debian.org/bookworm/ruby-daemons
- Licenses:
- Latest release: 1.4.1-1 (published 19 days ago)
- Last Synced: 2026-02-12T23:27:46.707Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-daemons
- Homepage: https://github.com/thuehlinger/daemons
- Documentation: https://packages.debian.org/trixie/ruby-daemons
- Licenses: mit
- Latest release: 1.4.1-2 (published 19 days ago)
- Last Synced: 2026-02-13T13:14:31.184Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- rake ~> 12.3, >= 12.3.3 development
- rspec ~> 3.1 development
- simplecov ~> 0 development
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 31.26521661822466