colinsurprenant / raad Goto Github PK
View Code? Open in Web Editor NEWRuby as a Daemon
License: Other
Ruby as a Daemon
License: Other
I can't start a simple service. Here is the output:
$ ruby lib/scheduler/runner.rb start
Raad service wrapper v0.5.0 starting
[4738:INFO] 2013-02-03 21:43:30 :: starting runner service in development mode
[4738:INFO] 2013-02-03 21:43:30 :: stopping runner service
[4738:INFO] 2013-02-03 21:43:30 :: >> Raad service wrapper stopped
Hi,
It would be great to have a restart command ? Do you plan to support it ?
I have a background job in which I need to access ActiveRecord models. If I start it without '-d', things work fine - I can access the database through AR models; but once I put '-d' in the command, the script doesn't work anymore.
I wonder if anybody has seen this before?
sh rvm_setup.sh
yields
rvm_setup.sh: 13: [[: not found rvm_setup.sh: 13: [[: not found ERROR: An RVM installation was not found.
Changing the [[]]'s to [] seems to help in some cases.
Also,
function waitline {...}
yields
function: not found
Changing it to
assert() {...}
lets it work
Can't get it working.
Here is a few more details about my approach: http://stackoverflow.com/questions/11457346/using-raad-and-eventmachine-in-cli-gem
Is it possible to use it like this, or am I using the wrong tool for this job?
Hello! Thanks for this gem!
I have an existing Thor-based command-line interface that I want to have start|stop to daemonize, but also needs a variety of other CLI options. The way the Raad gem is currently set up with bootstrapping, it appears to assume that the only command-line options are start/stop. It also seems to makes assumptions based on the current filename for service initiation that, in my case, would not make sense.
I can hack what I need together with some ideas from this gem, but this is what I would have loved to see:
in bin/my_app:
require 'raad'
require 'thor'
class MyApp < Thor
default_task :start
desc "Start My App", "Starts App Server"
def start
daemonize = true
if daemonize
Raad::Runner.new('ruby path_to_my_service_starter.rb').daemonize
else
MyServiceStarter.run
end
end
desc "Some other option I need"
def my_option
end
end
Or something to this effect. Not really an issue, just a suggestion. Thanks again.
In my application I did setup the environment in the initialize method.
So i changed it to 'my_env = Raad.env'
But it's always the default 'development' value.
If i move the statement to the start method it return the correct value (from the -e option)
any idea ?
first ^C will call the stop method and if the start thread still hangs, it will wait up to the defined timeout (default 60s) to force kill. a second ^C should provide a force kill shortcut.
it could be really helpful to provide a template /etc/init.d script of include a generator for it.
it could be useful to have an option to set the daemon working directory
I'm using raad along with jruby-jms to consume queues from activemq, it would be handy for deployment if I could specify where the log and pid files would be
postpone service class initialization after services setup to allow usage of logger in particular in the service initialize method.
currently there is no way to completely disable logging: in console mode by default logging is in the console and in daemon mode, logging is in the default log file.
jruby --1.9 service.rb -v -r service.stdout -d start
>> Raad service wrapper v0.5.0 starting
/.../gems/raad-0.5.0/lib/raad/env.rb:70: Use RbConfig instead of obsolete and deprecated Config.
Just a heads up and not directly related to RAAD.
Whenever RAAD is initiated, the following warning is generated:
.../gems/log4r-1.1.10/lib/log4r/formatter/patternformatter.rb:126 warning: Ambiguous first argument; make sure.
I sent in a pull request to fix it it in log4r: nbrochu/log4r@e54e97146c474cabc56e1da616b65393cc2b91bf
stop_service should only be called once, regardless if SIGINT or other signals are sent multiple times
Errno::ENOENT: No such file or directory -
mkdir at org/jruby/RubyDir.java:581
fu_mkdir at /home/jenko/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/1.9/fileutils.rb:247
mkdir_p at /home/jenko/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/1.9/fileutils.rb:221
reverse_each at org/jruby/RubyArray.java:1691
mkdir_p at /home/jenko/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/1.9/fileutils.rb:219
each at org/jruby/RubyArray.java:1611
mkdir_p at /home/jenko/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/1.9/fileutils.rb:205
setup_file_logger at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/logger.rb:42
setup at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/logger.rb:17
start_service at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/runner.rb:91
run at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/runner.rb:80
run! at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/bootstrap.rb:44
Raad at /home/jenko/.rvm/gems/jruby-1.7.0.preview1@barebones/gems/raad-0.5.0/lib/raad/bootstrap.rb:63
NameError: uninitialized constant MyServiceClass
const_missing at org/jruby/RubyModule.java:2715
(eval) at (eval):1
module_eval at org/jruby/RubyModule.java:2354
run! at /home/jenko/.rvm/gems/jruby-1.7.0.preview1/gems/raad-0.5.0/lib/raad/bootstrap.rb:43
Raad at /home/jenko/.rvm/gems/jruby-1.7.0.preview1/gems/raad-0.5.0/lib/raad/bootstrap.rb:63
this is when there is a mismatch between the command line service name and the actual class name which must match the camelcasing of the service name.
When the pid file is empty pid
and read_pid_file
methods return 0
, because en empty string is converted to zero by to_i
. And since process with pid 0 always exists in the system the daemon can't be started or restarted. That also happens for other non-integer content of the pid file
Empty pid file can occur when there's no space left on device. Additionally, number of bytes could be checked to distinguish this case (and maybe delete the pid file?).
Sorry if this is stupid question, but I am trying to pack a daemon in a JAR using warble. The script runs as expected in jruby, but once packed using warble and running:
java -jar Script.jar start
produces no output, no log, and just exists gracefully without any warning/error. how can I produce some logs to check why the daemon is not firing up?
Thanks in advance.
It would be nice to pass parameters to the service.
ex: before radd I did run the ruby with "ruby GetResponseByPop3.rb test"
with raad I run it with "ruby GetResponseByPop3.rb start"
but it would be nice to add -- test to pass my parameters
any idea , or I am wrong ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.