From 40501d53c0e10c5f8e5feb2e370a366a99e07a84 Mon Sep 17 00:00:00 2001 From: debbbbie Date: Mon, 8 Jun 2015 06:53:44 +0800 Subject: [PATCH 1/3] Update and rename README to README.md --- README => README.md | 67 +++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) rename README => README.md (91%) diff --git a/README b/README.md similarity index 91% rename from README rename to README.md index 607c206..c476154 100644 --- a/README +++ b/README.md @@ -1,8 +1,8 @@ -= Daemons Version 1.0.11 +# Daemons Version 1.0.11 (See Releases for release-specific information) -== What is Daemons? +## What is 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. @@ -17,66 +17,73 @@ if they crash. Daemons includes the daemonize.rb script written by Travis Whitton to do the daemonization process. -== Basic Usage +## Basic Usage You can use Daemons in four differet ways: -=== 1. Create wrapper scripts for your server scripts or applications +### 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 'rubygems' # if you use RubyGems 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 +### 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 'rubygems' # if you use RubyGems @@ -87,24 +94,27 @@ To run this code as a daemon create myproc_control.rb like this and inc 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 +``` +### 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 'rubygems' # if you use RubyGems @@ -134,12 +144,13 @@ server tasks as daemon processes. task2.stop exit - -=== 4. Daemonize the currently running process +``` +### 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 'rubygems' # if you use RubyGems @@ -156,37 +167,41 @@ Layout: you have an application my_daemon.rb that wants to run as a dae conn = accept_conn() serve(conn) } - +``` For further documentation, refer to the module documentation of Daemons. -== Download and Installation +## Download and Installation *Download*: just go to http://rubyforge.org/projects/daemons/ Installation *with* RubyGems: + +``` $ su # gem install daemons - +``` Installation *without* RubyGems: + +``` $ tar xfz daemons-x.x.x.tar.gz $ cd daemons-x.x.x $ su # ruby setup.rb - -== Documentation +``` +## Documentation For further documentation, refer to the module documentation of Daemons (click on Daemons). The RDoc documentation is also online at http://daemons.rubyforge.org -== Author +## Author Written in 2005-2008 by Thomas Uehlinger . -== License +## License Copyright (c) 2005-2008 Thomas Uehlinger @@ -218,6 +233,6 @@ The Daemonize extension module is copywrited free software by Travis Whitton . You can redistribute it under the terms specified in the COPYING file of the Ruby distribution. -== Feedback and other resources +## Feedback and other resources -At http://rubyforge.org/projects/daemons. +At [http://rubyforge.org/projects/daemons](). From f48dd618dd15a799ba5a584550c6c431cd3d46f1 Mon Sep 17 00:00:00 2001 From: debbbbie Date: Mon, 8 Jun 2015 06:57:24 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c476154..efb7240 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ You can use Daemons in four differet ways: Layout: suppose you have your self-written server myserver.rb: -``` +``` ruby # this is myserver.rb # it does nothing really useful at the moment @@ -39,7 +39,7 @@ in the background, release all directories and file descriptors). Just create myserver_control.rb like this: -``` +``` ruby # this is myserver_control.rb require 'rubygems' # if you use RubyGems @@ -49,7 +49,7 @@ Just create myserver_control.rb like this: ``` And use it like this from the console: -``` +``` bash $ ruby myserver_control.rb start (myserver.rb is now running in the background) $ ruby myserver_control.rb restart @@ -58,13 +58,13 @@ And use it like this from the console: ``` For testing purposes you can even run myserver.rb without forking in the background: -``` +``` bash $ 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_: -``` +``` bash $ ruby myserver_control.rb start -- --file=anyfile --a_switch another_argument ``` @@ -73,7 +73,7 @@ should be daemonized by seperating them by two _hyphens_: Layout: suppose you have some code you want to run in the background and control that background process from a script: -``` +``` ruby # this is your code # it does nothing really useful at the moment @@ -83,7 +83,7 @@ from a script: ``` To run this code as a daemon create myproc_control.rb like this and include your code: -``` +``` ruby # this is myproc_control.rb require 'rubygems' # if you use RubyGems @@ -97,7 +97,7 @@ To run this code as a daemon create myproc_control.rb like this and inc ``` And use it like this from the console: -``` +``` bash $ ruby myproc_control.rb start (myproc.rb is now running in the background) $ ruby myproc_control.rb restart @@ -106,7 +106,7 @@ And use it like this from the console: ``` For testing purposes you can even run myproc.rb without forking in the background: -``` +``` bash $ ruby myproc_control.rb run ``` ### 3. Control a bunch of daemons from another application @@ -114,7 +114,7 @@ For testing purposes you can even run myproc.rb without forking Layout: you have an application my_app.rb that wants to run a bunch of server tasks as daemon processes. -``` +``` ruby # this is my_app.rb require 'rubygems' # if you use RubyGems @@ -150,7 +150,7 @@ server tasks as daemon processes. 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) -``` +``` ruby # this is my_daemons.rb require 'rubygems' # if you use RubyGems @@ -178,13 +178,13 @@ Layout: you have an application my_daemon.rb that wants to run as a dae Installation *with* RubyGems: -``` +``` bash $ su # gem install daemons ``` Installation *without* RubyGems: -``` +``` bash $ tar xfz daemons-x.x.x.tar.gz $ cd daemons-x.x.x $ su From 810c2ae75948eb741b33083c46d22bbf759e3d77 Mon Sep 17 00:00:00 2001 From: debbbbie Date: Mon, 8 Jun 2015 06:59:12 +0800 Subject: [PATCH 3/3] Update daemons.gemspec --- daemons.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemons.gemspec b/daemons.gemspec index cf309ce..33a6883 100644 --- a/daemons.gemspec +++ b/daemons.gemspec @@ -10,8 +10,8 @@ Gem::Specification.new do |s| s.date = %q{2009-08-26} s.description = %q{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.} s.email = %q{th.uehlinger@gmx.ch} - s.extra_rdoc_files = ["README", "Releases", "TODO"] - s.files = ["Rakefile", "Releases", "TODO", "README", "LICENSE", "setup.rb", "lib/daemons.rb", "lib/daemons/cmdline.rb", "lib/daemons/exceptions.rb", "lib/daemons/daemonize.rb", "lib/daemons/pidfile.rb", "lib/daemons/monitor.rb", "lib/daemons/application_group.rb", "lib/daemons/controller.rb", "lib/daemons/pid.rb", "lib/daemons/pidmem.rb", "lib/daemons/application.rb", "examples/run", "examples/run/ctrl_exec.rb", "examples/run/ctrl_exit.rb", "examples/run/ctrl_multiple.rb", "examples/run/myserver_crashing.rb.output", "examples/run/ctrl_normal.rb", "examples/run/ctrl_proc_multiple.rb", "examples/run/ctrl_monitor.rb", "examples/run/myserver.rb", "examples/run/myserver_crashing.rb", "examples/run/ctrl_proc.rb", "examples/run/ctrl_proc.rb.output", "examples/run/ctrl_proc_multiple.rb.output", "examples/run/ctrl_optionparser.rb", "examples/run/ctrl_ontop.rb", "examples/run/myserver_exiting.rb", "examples/run/ctrl_crash.rb", "examples/run/ctrl_proc_simple.rb", "examples/run/ctrl_keep_pid_files.rb", "examples/call", "examples/call/call_monitor.rb", "examples/call/call.rb", "examples/daemonize", "examples/daemonize/daemonize.rb"] + s.extra_rdoc_files = ["README.md", "Releases", "TODO"] + s.files = ["Rakefile", "Releases", "TODO", "README.md", "LICENSE", "setup.rb", "lib/daemons.rb", "lib/daemons/cmdline.rb", "lib/daemons/exceptions.rb", "lib/daemons/daemonize.rb", "lib/daemons/pidfile.rb", "lib/daemons/monitor.rb", "lib/daemons/application_group.rb", "lib/daemons/controller.rb", "lib/daemons/pid.rb", "lib/daemons/pidmem.rb", "lib/daemons/application.rb", "examples/run", "examples/run/ctrl_exec.rb", "examples/run/ctrl_exit.rb", "examples/run/ctrl_multiple.rb", "examples/run/myserver_crashing.rb.output", "examples/run/ctrl_normal.rb", "examples/run/ctrl_proc_multiple.rb", "examples/run/ctrl_monitor.rb", "examples/run/myserver.rb", "examples/run/myserver_crashing.rb", "examples/run/ctrl_proc.rb", "examples/run/ctrl_proc.rb.output", "examples/run/ctrl_proc_multiple.rb.output", "examples/run/ctrl_optionparser.rb", "examples/run/ctrl_ontop.rb", "examples/run/myserver_exiting.rb", "examples/run/ctrl_crash.rb", "examples/run/ctrl_proc_simple.rb", "examples/run/ctrl_keep_pid_files.rb", "examples/call", "examples/call/call_monitor.rb", "examples/call/call.rb", "examples/daemonize", "examples/daemonize/daemonize.rb"] s.has_rdoc = true s.homepage = %q{http://daemons.rubyforge.org} s.require_paths = ["lib"]