mobalean

We ♥ web applications!

At mobalean we love to build innovative web services for Japan and the world. Our experience will help transform your ideas into successful online services.

» more

Mobalean is lead by Henri Servomaa, the original founder and mobile developer. At Mobalean we strive to develop services which are loved by our clients and users. By working in an agile manner, quickly adapting to changing requirements, we can deliver quickly and often.

Henri Servomaa

Henri

Hailing from Finland, Henri has a long history with computers and the internet. With a background in Electrical Engineering and Computer Science, he has worked in Japan as Software Developer and System Admin since 2001. In 2005, he joined a company to develop mobile sites for the Japanese market and has been involved in mobile ever since.

Email
Email
Twitter
Twitter
Facebook
Facebook
Linkedin
Linkedin
github
github

Contractors

Cleve

Cleve Lendon is a Canadian engineer who has been contracting for Mobalean. He came to Tokyo in 1994, and has lived here ever since. He has broad experience as a software developer, which includes development of mainframe software, Internet applications and mobile apps (Android and iOS). He is especially skilled at writing Java applications (vd. Simredo 4, Grafikilo 15). When not programming, Cleve enjoys improv acting and studying languages, such as Latin and Esperanto.

Facebook
Facebook

Mobalean Alumni

Paul McMahon and Michael Reinsch were co-founders of Mobalean. They have moved to Doorkeeper KK, a company they established in 2013. Both are now actively developing the doorkeeper platform.

Web Development

Our strength is crafting web services for both Japanese and international markets. We bring our technical and cultural experience to help you adapt your ideas into successful products.

We develop with Ruby on Rails and use the best agile practices and tools, such as test driven development and continuous integration to achieve quality.

Japanese Mobile Consulting

We are the leading provider of technical expertise about the Japanese mobile web. Mobalean started when the smartphones were just appearing on the market. Our Keitai Web Technology Guide is a quick starting point for learning about the initial challenges of Japanese mobile development. Although the technology stacks have changed since the proliferation of iOS and Android, some of the idiosyncrasies remain. Most notably, the Japanese market is still very much dominated by the big three carriers: DoCoMo, au and Softbank. Developers can find more technical details in our Keitai-Dev Wiki.


Please contact us with your specific requirements.

Others

Originally developed here, Doorkeeper can now be found at doorkeeper inc.

Some of our clients

  • Reaktor Japan KK.

    Reaktor Japan, KK..

    http://www.reaktor.co.jp/
  • Ubiquitous Business Technology, Inc.

    Ubiquitous Business Technology, Inc.

    http://www.ubit.com/
  • PayPal Pte. Ltd.

    PayPal Pte. Ltd.

    http://www.paypal.com/
  • Robert Bosch Co., Ltd.

    Robert Bosch Co., Ltd.

    http://www.bosch.com/
  • GILT GROUPE K.K.

    GILT GROUPE K.K.

    http://www.gilt.jp/
  • Cerego Japan Inc.

    Cerego Japan Inc.

    http://www.cerego.com/
  • GMAP KK

    GMAP KK

    http://gmap.jp/
  • Mobikyo K.K.

    Mobikyo K.K.

    http://mobikyo.jp/
  • Native Creative Services

    Native Creative Services

    http://www.gonative.jp/
  • InnoviData GmbH

    InnoviData GmbH

    http://www.innovidata.de/
  • Sairis Group, KK

    Sairis Group, KK

    http://www.sairis.com/
  • Gerd Leonhard, MediaFuturist.com

    Gerd Leonhard, MediaFuturist.com

    http://www.mediafuturist.com/
  • Script Interactive

    Script Interactive

    http://www.script-interactive.com/

Send us a message

    

Send us an email

Email address: info@mobalean.com

Call us

If you prefer to call us, feel free to do so under +81 (0)70-6251-7245
For users of Skype, please call mobalean

delayed_job (and other daemons) in a production environment

  

Posted by Michael Reinsch on 2010-08-16

The delayed_job plugin for Rails does a good job for pushing tasks that take some time to process into the background, so that your users (and your Rails processes) can do other things than to wait. It uses daemons to process the backgrounded tasks, so for your system to work correctly it is essential that those daemons are running. Thus you want to make sure that those daemons are getting started when the server boots and are restarted in case they die. Those points are not addressed by delayed_job.

The usual way to get processes started at boot time under Linux is to use an init.d script. But init.d scripts only address the boot process - if the daemon dies, it won't get restarted.

D.J. Bernstein's daemontools make it very simple to create system services which achieve both of the above points: starting your daemons at system boot time and restarting them in case they die. And the best feature: to create a new service, you don't even need to include any of the typical daemon features (such as backgrounding the process) into your program. So while delayed_job uses the daemons library to provide those features, we won't be needing those.

The following steps show how to set up a new service. This assumes that you already installed daemontools (available for Ubuntu/Debian for instance: apt-get install daemontools-run).

  1. Create a new directory. This is going to be the service directory.
  2. Create a shell script "run" in the service directory which runs your program. This can be as simple as exec /path/to/my/program.
  3. Create a symlink from the system service directory (for Ubuntu that'd be /etc/service), pointing to your new service directory.

That's it. To control your service, use the svc tool. See the manpage for more information.

In case of delayed_job, we are using the following run script:

#!/bin/sh
export RAILS_ENV=production
exec 2>/dev/null
exec setuidgid railsuser /srv/railsuser/project/current/script/delayed_job run

The script changes the user to "railsuser" (you don't want to run your delayed job processing under root; change it to match your setup), and then starts the usual delayed_job script, telling it to not put itself into the background.

One specialty to note is the handling of stderr. We redirect it to /dev/null to avoid potential "Broken pipe" exceptions in case something writes to stderr, which isn't available. Redirecting sdterr to stdout did not work.

Now, when updating, you will want to restart the delayed_job service. With capistrano we use the following task definitions:

namespace :delayed_job do
  desc "Start delayed job (if not running)"
  task :start, :roles => :app do
    sudo "svc -u /etc/service/#{application}_#{rails_env}_delayed_job"
  end
  desc "Stop delayed job"
  task :stop, :roles => :app do
    sudo "svc -d /etc/service/#{application}_#{rails_env}_delayed_job"
  end
  desc "Restart delayed job"
  task :restart, :roles => :app do
    sudo "svc -t /etc/service/#{application}_#{rails_env}_delayed_job"
  end
end

after "deploy:start", "delayed_job:start" 
after "deploy:stop", "delayed_job:stop" 
after "deploy:restart", "delayed_job:restart"

This requires that your deployment user will be able to run svc using sudo, so make sure to add this to your sudoers.

Also note that for the service names in the system service directory we use the pattern #{application}_#{rails_env}_delayed_job. Those are links to the service's directory, which are located under /srv/railsuser/project/services for our setup.

With this setup we have a pretty reliable delayed_job, and can use the same framework to run most (if not all) other services we might need with very little effort.

  



Archive

2021-01-12   Upgrading Rails, 3.2 to 5.2
2016-12-05   Upgrading Ruby, 1.8 to 2.3
2016-02-16   Do you have entropy?
2015-11-09   Asset Pipeline for Clojure
2015-10-29   New logo for mobalean and other announcements
2013-03-03   Keeping your database in sync with your current branch
2013-02-24   Running Rails tests on a CI server
2013-01-31   Text Files as a CMS
2012-10-05   Truncating Text With CSS
2012-09-28   Mobalean becomes a Heroku partner
2012-05-08   Cleaning up your CSS with selectors
2012-03-15   請求書.jpのスタンドファーム社への譲渡について
2012-01-13   The Joy of Gems: Cooking up Rails Plugins
2011-09-08   Dynamic Methods vs. Method Missing
2011-09-02   Guessing a String's Encoding Under Ruby 1.9
2011-08-02   PDF generation and Heroku
2011-07-20   A Step Towards Internationalizing the Japanese Ruby Community
2011-07-14   Rubyを使っての英語学習
2011-06-29   Using the Asset Pipeline under Rails 3.1
2010-12-03   Updating a real world application to Rails 3
2010-11-19   Seamless Rails integration with jQuery Tools Dateinput
2010-11-12   Kara-mail for Japanese mobile sites
2010-10-14   Challenges faced creating a mobile site in Japan
2010-09-02   Announcing Tokyo Rubyist Meetup
2010-08-20   Keitai Web Technology Guide
2010-08-16   delayed_job (and other daemons) in a production environment
2010-07-04   Announcing Doorkeeper: Easy Event Ticketing and Check-in
2010-04-09   Enabling url parameter based sessions in Ruby on Rails
2010-02-15   Mobalean and Keitai-dev Wiki merge
2010-02-05   mobalean WURFL patch merged into core WURFL
2010-01-27   IMJ Mobile Releases Free Collection of Mobile Surveys
2009-12-04   KEITAIALL: Specs on all Japanese Mobiles
2009-11-19   Betrend releases report on mobile access in Japan
2009-11-16   XHTML support and Japanese Carriers
2009-06-10   mobalean releases Japanese WURFL patch, ruby libraries
2009-05-22   docomo to support JavaScript, external CSS, cookies, and more
2009-05-15   New docomo handsets to support cookies and send referrers?
2009-03-16   Japanese Mobile Support for Cake PHP
2009-03-05   mobalean to present at next Tokyo 2.0
2009-03-02   emobile wireless Internet access with Linux
2009-02-28   Hacking Ruby's default arguments
2009-02-25   docomo to launch SNS
2009-02-10   Ninjava Presentation
2009-02-10   Six weeks in
2009-02-06   Automatic Deployment via git
2009-02-01   Hosting git repositories
2009-01-30   mobalean Blog Live

mobalean

  • Home
  • About
  • Services
  • Clients
  • Contact
  • Blog

Social Links

Twitter
Facebook

Recent blogs

  • Upgrading Rails, 3.2 to 5.2
  • Upgrading Ruby, 1.8 to 2.3
  • Do you have entropy?
  • Asset Pipeline for Clojure
  • New logo for mobalean and other announcements

© 2009 - 2025 mobalean