Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5960113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:46:51+00:00 2026-05-22T18:46:51+00:00

Hi I need to build an ruby on rails application which will call every

  • 0

Hi
I need to build an ruby on rails application which will call every 1 second to a remote Api url, in order to catch an event that should be occurred in that remote web server
the url is

“remoteservername.com/folder/folder/waitforevents”

once the wanted event is occurred I need to perform some actions and call again to the “remoteservername.com/folder/folder/waitforevents” url.
This should be a continuously task and done without the opening of a browser. It means that this application should start running immediately after my web server is started.

so my question is how can I run a ruby on rails application without opening the browser
just the server

until now I had experience in writing rails applications which started when the browser was opened and some url was invoked.
so I will be glad if you could guide me on this issue

THANKS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:46:52+00:00Added an answer on May 22, 2026 at 6:46 pm

    You may use cron together with ./script/rails runner, which can execute any method from your rails application.

    Since you need to execute some action every second, you may start that runner once, and create a loop. You may start it from the cron, save the PID somewhere and later ask the cron to kill given process, OR you may just timeout in your Ruby code, in the loop. A simple example:

    class MyModelOrAnything
      def self.start_loop
        stop_fname = "./stop_the_loop"
        while !File.exist? stop_fname 
          do_this_action
          sleep 1
        end
      ensure
        File.unlink stop_fname  if File.exist? stop_fname
      end
    end
    

    A cron task may then create a file “stop_the_loop” in known directory, and your task will stop after a second.

    In fact, cron may not be necessary in this case. Since you should have only one instance of this script, it would be better to start it manually, and stop it manually. If you want to use cron, you could add a semaphore-like file, which will tell the script that one process is already running (The file should be removed by the ‘ensure’ block).

    An example of the cron config:

    0 8  * * 1 cd /my/app && bundle exec ./script/rails runner ThisObject.start_loop
    0 22 * * 5 touch /my/app/stop_the_loop
    

    ..and an example with this ‘semaphore’:

    class MyModelOrAnything
      def self.start_loop
        running_fname = "./i_am_working"
        return :already_running if File.exist? running_fname
        stop_fname = "./stop_the_loop"
        begin
          File.open(running_fname,'w') {|f| f.write Time.now.to_s(:db) }
          while !File.exist? stop_fname 
            do_this_action
            sleep 1
          end
        ensure
          File.unlink running_fname if File.exist? running_fname
          File.unlink stop_fname  if File.exist? stop_fname
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build a function which parses the domain from a URL. So,
I'm about to build my first Ruby on Rails application (and first anything beyond
I am trying to build a free web application using ruby/rails It should be
I need to build a simple, single user database application for Windows. Main requirements
We need to build an administration portal website to support our client/server application. Since
I'm using Ruby on Rails to develop a web application. I have a wiki
I'm a 80% ruby on rails developer, but still need to do some Access
I just installed Ruby EE 11.01. I had a Rails 2.3.8 application that was
I have built a Ruby on Rails (2.3.8) application that allows users to track
I am using Ruby on Rails 3 and I am trying to build an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.