Search code examples
rubybundlergemfileappfogrufus-scheduler

AppFog background worker 'failed to start'


I'm trying to follow the AppFog guide on creating a background worker in ruby, and I'm running into some (probably noob) issues. The example uses Rufus-scheduler, which (according to the Ruby docs on AppFog) means I need to use Bundler to include/manage within my app. Nonetheless, I've run bundle install, pushed everything to AppFog in the appropriate ('standalone') fashion, and still can't seem to get it running.

my App & Gemfile: enter image description here

...and via the AF CLI:

$ af push
[...creating/uploading/etc. etc... - removed to save space]
Staging Application 'chservice-dev': OK                                         
Starting Application 'chservice-dev': .

Error: Application [chservice-dev] failed to start, logs information below.

====> /logs/staging.log <====

# Logfile created on 2013-06-27 20:22:23 +0000 by logger.rb/25413
Need to fetch tzinfo-1.0.1.gem from RubyGems
Adding tzinfo-1.0.1.gem to app...
Adding rufus-scheduler-2.0.19.gem to app...
Adding bundler-1.1.3.gem to app...

====> /logs/stdout.log <====

2013-06-27 20:22:28.841 - script executed.

Delete the application? [Yn]: 

How can I fix (or troubleshoot) this? I'm probably missing a large step/concept... very new to ruby =)

Thanks in advance.


Solution

  • I think the app might be exiting immediately. The scheduler needs to be joined to the main thread in order to keep that app running.

    require 'rubygems'
    require 'rufus/scheduler'
    
    scheduler = Rufus::Scheduler.start_new
    
    scheduler.every '10s' do
      puts 'Log this'
    end
    
    ### join the scheduler to the main thread ###
    scheduler.join
    

    I created a sample rufus scheduler app that works on appfog: https://github.com/tsantef/appfog-rufus-example