Daemons do not get restarted?
up vote
3
down vote
favorite
I am trying to run the same script in multiple daemons.
myapp.rb
looks like this:
loop do
sleep 5
1 / 0 # crash it
end
my myapp_controller.rb
:
require 'rubygems'
require 'daemons'
options =
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => true,
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
When I run ruby myapp_controller.rb start
several times in a row, it creates that many daemons, as I expect. But, after a while, due to an error in myapp.rb
the daemons crash and the monitor restarts just one and not all. So I end up with a single running daemon.
Why? What am I doing wrong?
ruby daemons
add a comment |
up vote
3
down vote
favorite
I am trying to run the same script in multiple daemons.
myapp.rb
looks like this:
loop do
sleep 5
1 / 0 # crash it
end
my myapp_controller.rb
:
require 'rubygems'
require 'daemons'
options =
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => true,
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
When I run ruby myapp_controller.rb start
several times in a row, it creates that many daemons, as I expect. But, after a while, due to an error in myapp.rb
the daemons crash and the monitor restarts just one and not all. So I end up with a single running daemon.
Why? What am I doing wrong?
ruby daemons
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am trying to run the same script in multiple daemons.
myapp.rb
looks like this:
loop do
sleep 5
1 / 0 # crash it
end
my myapp_controller.rb
:
require 'rubygems'
require 'daemons'
options =
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => true,
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
When I run ruby myapp_controller.rb start
several times in a row, it creates that many daemons, as I expect. But, after a while, due to an error in myapp.rb
the daemons crash and the monitor restarts just one and not all. So I end up with a single running daemon.
Why? What am I doing wrong?
ruby daemons
I am trying to run the same script in multiple daemons.
myapp.rb
looks like this:
loop do
sleep 5
1 / 0 # crash it
end
my myapp_controller.rb
:
require 'rubygems'
require 'daemons'
options =
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => true,
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
When I run ruby myapp_controller.rb start
several times in a row, it creates that many daemons, as I expect. But, after a while, due to an error in myapp.rb
the daemons crash and the monitor restarts just one and not all. So I end up with a single running daemon.
Why? What am I doing wrong?
ruby daemons
ruby daemons
edited Jan 25 '13 at 16:58
asked Jan 25 '13 at 4:16
akonsu
16.4k2187154
16.4k2187154
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
I was able to reproduce the behavior. It is not anything you are doing wrong; it is the way the daemons gem
behaves.
Going through the code for the daemons gem, turns out the :multiple
option doesn't work well with the :monitor
option.
The :monitor
option works only when the daemon is run in single mode.
I have created a bug report on the daemons project page referencing this question as the source.
More info about the reproduction of the issue:
Multiple daemon processes are created when :multiple => true
. Each process has its own pid file in the format of <scriptname>.rb<number>.pid
.
However, only one monitor process is created (with a single <scriptname>.rb_monitor.pid
file.)
Here are the list of processes started when I start the daemon process 3 times:
$ ps -fe | grep my_server
501 1758 1 0 12:25PM ?? 0:00.63 my_server.rb
501 1759 1 0 12:25PM ?? 0:00.43 my_server.rb_monitor
501 1764 1 0 12:25PM ?? 0:00.54 my_server.rb
501 1834 1 0 12:51PM ?? 0:00.31 my_server.rb
The files in the pid/log folder:
$ ls /tmp/daemons-2013-01-25/
my_server.rb.log my_server.rb1.pid my_server.rb_monitor.pid
my_server.rb0.pid my_server.rb2.pid
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
add a comment |
up vote
0
down vote
Until the issue is resolved, you can change your code to something like this:
#myapp_controller.rb
require 'rubygems'
require 'daemons'
number = ARGV.fetch(1)
options =
:app_name => "daemon-#number" # provide app_name
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => false, # disable multiple option
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
And then start your daemons with these commands:
ruby myapp_controller.rb start 1
ruby myapp_controller.rb start 2
...
This slightly changes your startup code, but now you will have a monitor process for each of your daemon processes.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
I was able to reproduce the behavior. It is not anything you are doing wrong; it is the way the daemons gem
behaves.
Going through the code for the daemons gem, turns out the :multiple
option doesn't work well with the :monitor
option.
The :monitor
option works only when the daemon is run in single mode.
I have created a bug report on the daemons project page referencing this question as the source.
More info about the reproduction of the issue:
Multiple daemon processes are created when :multiple => true
. Each process has its own pid file in the format of <scriptname>.rb<number>.pid
.
However, only one monitor process is created (with a single <scriptname>.rb_monitor.pid
file.)
Here are the list of processes started when I start the daemon process 3 times:
$ ps -fe | grep my_server
501 1758 1 0 12:25PM ?? 0:00.63 my_server.rb
501 1759 1 0 12:25PM ?? 0:00.43 my_server.rb_monitor
501 1764 1 0 12:25PM ?? 0:00.54 my_server.rb
501 1834 1 0 12:51PM ?? 0:00.31 my_server.rb
The files in the pid/log folder:
$ ls /tmp/daemons-2013-01-25/
my_server.rb.log my_server.rb1.pid my_server.rb_monitor.pid
my_server.rb0.pid my_server.rb2.pid
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
add a comment |
up vote
4
down vote
accepted
I was able to reproduce the behavior. It is not anything you are doing wrong; it is the way the daemons gem
behaves.
Going through the code for the daemons gem, turns out the :multiple
option doesn't work well with the :monitor
option.
The :monitor
option works only when the daemon is run in single mode.
I have created a bug report on the daemons project page referencing this question as the source.
More info about the reproduction of the issue:
Multiple daemon processes are created when :multiple => true
. Each process has its own pid file in the format of <scriptname>.rb<number>.pid
.
However, only one monitor process is created (with a single <scriptname>.rb_monitor.pid
file.)
Here are the list of processes started when I start the daemon process 3 times:
$ ps -fe | grep my_server
501 1758 1 0 12:25PM ?? 0:00.63 my_server.rb
501 1759 1 0 12:25PM ?? 0:00.43 my_server.rb_monitor
501 1764 1 0 12:25PM ?? 0:00.54 my_server.rb
501 1834 1 0 12:51PM ?? 0:00.31 my_server.rb
The files in the pid/log folder:
$ ls /tmp/daemons-2013-01-25/
my_server.rb.log my_server.rb1.pid my_server.rb_monitor.pid
my_server.rb0.pid my_server.rb2.pid
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
I was able to reproduce the behavior. It is not anything you are doing wrong; it is the way the daemons gem
behaves.
Going through the code for the daemons gem, turns out the :multiple
option doesn't work well with the :monitor
option.
The :monitor
option works only when the daemon is run in single mode.
I have created a bug report on the daemons project page referencing this question as the source.
More info about the reproduction of the issue:
Multiple daemon processes are created when :multiple => true
. Each process has its own pid file in the format of <scriptname>.rb<number>.pid
.
However, only one monitor process is created (with a single <scriptname>.rb_monitor.pid
file.)
Here are the list of processes started when I start the daemon process 3 times:
$ ps -fe | grep my_server
501 1758 1 0 12:25PM ?? 0:00.63 my_server.rb
501 1759 1 0 12:25PM ?? 0:00.43 my_server.rb_monitor
501 1764 1 0 12:25PM ?? 0:00.54 my_server.rb
501 1834 1 0 12:51PM ?? 0:00.31 my_server.rb
The files in the pid/log folder:
$ ls /tmp/daemons-2013-01-25/
my_server.rb.log my_server.rb1.pid my_server.rb_monitor.pid
my_server.rb0.pid my_server.rb2.pid
I was able to reproduce the behavior. It is not anything you are doing wrong; it is the way the daemons gem
behaves.
Going through the code for the daemons gem, turns out the :multiple
option doesn't work well with the :monitor
option.
The :monitor
option works only when the daemon is run in single mode.
I have created a bug report on the daemons project page referencing this question as the source.
More info about the reproduction of the issue:
Multiple daemon processes are created when :multiple => true
. Each process has its own pid file in the format of <scriptname>.rb<number>.pid
.
However, only one monitor process is created (with a single <scriptname>.rb_monitor.pid
file.)
Here are the list of processes started when I start the daemon process 3 times:
$ ps -fe | grep my_server
501 1758 1 0 12:25PM ?? 0:00.63 my_server.rb
501 1759 1 0 12:25PM ?? 0:00.43 my_server.rb_monitor
501 1764 1 0 12:25PM ?? 0:00.54 my_server.rb
501 1834 1 0 12:51PM ?? 0:00.31 my_server.rb
The files in the pid/log folder:
$ ls /tmp/daemons-2013-01-25/
my_server.rb.log my_server.rb1.pid my_server.rb_monitor.pid
my_server.rb0.pid my_server.rb2.pid
answered Jan 25 '13 at 9:22
Prakash Murthy
11k32859
11k32859
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
add a comment |
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
The bug report given in the post appears to be a broken link. Here is an issue page on github. github.com/thuehlinger/daemons/issues/7
– rude-n8
Aug 25 '15 at 18:10
add a comment |
up vote
0
down vote
Until the issue is resolved, you can change your code to something like this:
#myapp_controller.rb
require 'rubygems'
require 'daemons'
number = ARGV.fetch(1)
options =
:app_name => "daemon-#number" # provide app_name
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => false, # disable multiple option
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
And then start your daemons with these commands:
ruby myapp_controller.rb start 1
ruby myapp_controller.rb start 2
...
This slightly changes your startup code, but now you will have a monitor process for each of your daemon processes.
add a comment |
up vote
0
down vote
Until the issue is resolved, you can change your code to something like this:
#myapp_controller.rb
require 'rubygems'
require 'daemons'
number = ARGV.fetch(1)
options =
:app_name => "daemon-#number" # provide app_name
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => false, # disable multiple option
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
And then start your daemons with these commands:
ruby myapp_controller.rb start 1
ruby myapp_controller.rb start 2
...
This slightly changes your startup code, but now you will have a monitor process for each of your daemon processes.
add a comment |
up vote
0
down vote
up vote
0
down vote
Until the issue is resolved, you can change your code to something like this:
#myapp_controller.rb
require 'rubygems'
require 'daemons'
number = ARGV.fetch(1)
options =
:app_name => "daemon-#number" # provide app_name
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => false, # disable multiple option
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
And then start your daemons with these commands:
ruby myapp_controller.rb start 1
ruby myapp_controller.rb start 2
...
This slightly changes your startup code, but now you will have a monitor process for each of your daemon processes.
Until the issue is resolved, you can change your code to something like this:
#myapp_controller.rb
require 'rubygems'
require 'daemons'
number = ARGV.fetch(1)
options =
:app_name => "daemon-#number" # provide app_name
:log_output => true,
:backtrace => true,
:monitor => true,
:multiple => false, # disable multiple option
:log_dir => '/mnt/log/',
:hard_exit => true
Daemons.run(File.join(File.dirname(__FILE__), 'myapp.rb'), options)
And then start your daemons with these commands:
ruby myapp_controller.rb start 1
ruby myapp_controller.rb start 2
...
This slightly changes your startup code, but now you will have a monitor process for each of your daemon processes.
answered Nov 11 at 17:18
kolchan11
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14515250%2fdaemons-do-not-get-restarted%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown