init.d script #15

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
@thedotedge

Hi Chris!
The problem I had with workers is that they have to be started somehow: when a box goes down, you have to make sure you start them again automatically.
So I've thrown together a simple script that alongside with monit does the trick (tested on CentOS 5). Just copy it to /etc/init.d/php-resque.
Monit config snippet:
check process php-resque with pidfile /var/run/php-resque/php-resque.pid group queues start program = "/etc/init.d/php-resque start" stop program = "/etc/init.d/php-resque stop" if 5 restarts within 5 cycles then timeout

Current limitation is that it does only support 1 worker.

@creativvn

This comment has been minimized.

Show comment Hide comment
@creativvn

creativvn Dec 5, 2012

I suggest you config this using Supervisor instead of. Set numprocs to the number of workers you want
Sample program in supervisor for this

[program:resque]
directory = /path/to/script/
command = php index.php
environment = QUEUE=*
stopsignal = QUIT
stderr_logfile = /var/log/supervisor/%(program_name)s_error-%(process_num)s.log
stdout_logfile = /var/log/supervisor/%(program_name)s-%(process_num)s.log
numprocs = 2
process_name = "%(program_name)s-%(process_num)s"

I suggest you config this using Supervisor instead of. Set numprocs to the number of workers you want
Sample program in supervisor for this

[program:resque]
directory = /path/to/script/
command = php index.php
environment = QUEUE=*
stopsignal = QUIT
stderr_logfile = /var/log/supervisor/%(program_name)s_error-%(process_num)s.log
stdout_logfile = /var/log/supervisor/%(program_name)s-%(process_num)s.log
numprocs = 2
process_name = "%(program_name)s-%(process_num)s"

@jbrower

This comment has been minimized.

Show comment Hide comment
@jbrower

jbrower Jan 13, 2013

It's nice having an autostart script, but before a really effective method can be used, the way that resque forks off additional workers when COUNT > 1 should be changed. That way there is just one process to manage regardless of how many workers you have on that server.

jbrower commented Jan 13, 2013

It's nice having an autostart script, but before a really effective method can be used, the way that resque forks off additional workers when COUNT > 1 should be changed. That way there is just one process to manage regardless of how many workers you have on that server.

@jbrower

This comment has been minimized.

Show comment Hide comment
@jbrower

jbrower Jan 28, 2013

Pull request #83 seems to fix the issue that I explained. It provides one management process that takes care of everything else.

jbrower commented Jan 28, 2013

Pull request #83 seems to fix the issue that I explained. It provides one management process that takes care of everything else.

@danhunsaker

This comment has been minimized.

Show comment Hide comment
@danhunsaker

danhunsaker Mar 9, 2013

Contributor

Init scripts don't tend to be included with the master source code for a given project. This is mostly due to the differences between init script formatting and handling between different systems, though the fact that several operating system environments don't even use them to begin with contributes as well.

There are a number of solutions to this. One is to include a different init script for every system that is "supported" and let the user install the appropriate one for their system. The best, though, is usually to leave this to implementers, be they sysadmins, developers, or OS/package-manager maintainers.

That said, it's also useful to see what such scripts might look like in the meantime.

Contributor

danhunsaker commented Mar 9, 2013

Init scripts don't tend to be included with the master source code for a given project. This is mostly due to the differences between init script formatting and handling between different systems, though the fact that several operating system environments don't even use them to begin with contributes as well.

There are a number of solutions to this. One is to include a different init script for every system that is "supported" and let the user install the appropriate one for their system. The best, though, is usually to leave this to implementers, be they sysadmins, developers, or OS/package-manager maintainers.

That said, it's also useful to see what such scripts might look like in the meantime.

@ruudk

This comment has been minimized.

Show comment Hide comment
@ruudk

ruudk Mar 13, 2013

Contributor

Why not just make a tutorial for it on the Wiki? I managed to do it using Supervisord and it works fine. No need for this to be included.

Contributor

ruudk commented Mar 13, 2013

Why not just make a tutorial for it on the Wiki? I managed to do it using Supervisord and it works fine. No need for this to be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment