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 8327221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:02:10+00:00 2026-06-09T01:02:10+00:00

I am initiating long running processes from a browser and showing results after it

  • 0

I am initiating long running processes from a browser and showing results after it completes. I have defined in my controller :

def runthejob
   pid = Process.fork
   if pid.nil? then   
    #Child
    output = execute_one_hour_job()
    update_output_in_database(output)
    # Exit here as this child process shouldn't continue anymore
    exit  
   else
    #Parent
    Process.detach(pid)
    #send response - job started...
end
  1. The request in parent completes correctly. But , in child, there is always a “500 internal server error” . rails reports “Completed 500 Internal Server Error in 227192ms” . I am guessing this happens because the request response cycle of the child process is not completed as there is a “exit” in child. How do I fix this?

  2. Is this the correct way to execute long running processes ? Is there any better way to do it?

  3. When child is running, if I do “ps -e | grep rails” , I see that there are two instances of “rails server” . (I use the command “rails server” to start my rails server.)

    ps -e | grep rails
    75678 ttys002 /Users/xx/ruby-1.9.3-p194/bin/ruby script/rails server
    75696 ttys002 /Users/xx/ruby-1.9.3-p194/bin/ruby script/rails server

Does this mean that there are two servers running ? How are the requests handled now? Wont the request go to the second server?

Thanks for helping me.

  • 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-06-09T01:02:13+00:00Added an answer on June 9, 2026 at 1:02 am

    Try your code in production and see if the same error comes up. If not, your error may be from the development environment being cleared when the first request completes, whilst your forks still need the environment to exist. I haven’t verified this with forks, but that is what happens with threads.

    This line in your config/development.rb will retain the environment, but any code changes will require server restarts.

    config.cache_classes = true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JavaScript from a 3rd party vendor that is initiating an image
After initiating a new project, I would like to know when Petrel has completed
After initiating a new SimpleXml object: $xml = new SimpleXML($xmlStr); PHP errors out: Fatal
Connect function returns after sending the last ACK(3rd segment of 3-way handshake of initiating
My work place recently started a SOA initiative. After a year-long examination of the
I have a strange problem by initiating a class object. The problem is as
I currently have a .NET program initiating a connection to a server. Sometimes I
Trying to create a request only to have a runtime error thrown. Method initiating
We have a web application written in PHP that exports MySQL query results to
I'm running a long process stored procedure. I'm wondering if in case of a

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.