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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:35:16+00:00 2026-06-01T22:35:16+00:00

I have a rake task that deletes some files. It is possible for these

  • 0

I have a rake task that deletes some files. It is possible for these files to be in active use by the application. Due to what I suspect are some peculiarities of the file system I’m running on (AFS), I can’t delete the files while the app (and the server) are running.

I’d like to abort early if the server is running. Is there any way to check whether the server started by script/generate is running while inside of a rake task?

  • 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-01T22:35:18+00:00Added an answer on June 1, 2026 at 10:35 pm

    You can check for the existence of tmp/pids/server.pid, which rails s will create when it starts, and should remove when it exits. Note that if the server didn’t exit cleanly, the file could still be around, so you should read the PID from the file and check if it is in fact running:

    path = File.join(Rails.root, "tmp", "pids", "server.pid")
    pid = File.read(path).to_i
    server_running = true
    begin
      Process.getpgid pid
    rescue Errno::ESRCH
      server_running = false
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rake task that uploads a list of files via ftp. Copying
I have a rake task that populates some initial data in my rails app.
I have a rake task that pulls and parses JSON data over an SSL
I have a rake task to seed an application with random data using the
I have a rake task where I do some checks at the beginning, if
I have some rake tasks that run each minute and of course that spawns
I have a rake task that runs, quite a lot of code. At the
I have a rake task that sends out the next 'x' invitations to join
I have seen some apps that have a few rake tasks included to load
I have a rake task that performs a shell command. When I run it

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.