On Sun, Mar 03, 2013 at 12:26:36PM -0800, Tony Jiang wrote:
>
> I guess I was looking for something elegant and doesn't involve the shell.
> Some things that look like *scheduler.detach, Rufus.schedulers &
> scheduler.exit, Rufus.exit_all_schedulers,* etc. so that I can do 'bundle
> exec rake scheduler:stop'.
Hello Tony,
sorry, rufus-scheduler is a library, not an application.
All the methods you mention imply design decisions, like the one you took in
the code below when you decided to take the first listed processed that
matched the "scheduler:start" string. Another classic would have been to go
with a PID file.
Your design decisions certainly conflict with other integrators' design
decisions.
There are a lot of daemon tools for Ruby out there, better to let integrators
pick the one they know and like and fits their use case.
> This actually works inside the rake task *stop*:
>
> * processes = systemu("ps eu")[1].split("\n")*
> * command = processes.find {|process| process =~ /scheduler:start/}*
> * process_id = command.split(" ")[1]*
> * systemu("kill -9 #{process_id}")*
>
> Not ideal, but might be my final solution.
Might be ideal if you're OK with 1+ scheduling process.