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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:13:46+00:00 2026-05-15T19:13:46+00:00

If ruby myapp.rb starts sinatra previewing at localhost:4567, how can I programatically stop/halt/kill it?

  • 0

If ruby myapp.rb starts sinatra previewing at localhost:4567, how can I programatically stop/halt/kill it? Terminal command (other than Ctrl-C), or Rake tasks would be fine.

I need to incorporate this into a Rake task or terminal.

  • 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-15T19:13:48+00:00Added an answer on May 15, 2026 at 7:13 pm

    In myapp.rb, add this before sinatra starts:

    puts "This is process #{Process.pid}"
    

    When you want to kill it, do this in a shell:

    kill <pid>
    

    Where <pid> is the number outputted by myapp.rb. If you want to do it in ruby:

    Process.kill 'TERM', <pid>
    

    Both of these will let sinatra run it’s exit routine. If you don’t want to type in the pid every time, have myapp.rb open a file and put it’s pid in it. Then when you want to stop it, read the file and use that. Example:

    # myapp.rb:
    File.open('myapp.pid', 'w') {|f| f.write Process.pid }
    
    # shell:
    kill `cat myapp.pid`
    
    # ruby:
    Process.kill 'TERM', File.read('myapp.pid')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I finally got it working with this piece of code:… May 16, 2026 at 4:15 pm
  • Editorial Team
    Editorial Team added an answer What you need is a distance function that can handle… May 16, 2026 at 4:15 pm
  • Editorial Team
    Editorial Team added an answer I was not using tortoisesvn or any other client, i… May 16, 2026 at 4:15 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Using Sinatra in Ruby you can set the server's settings by doing: set :myvariable,
With Ruby you can do gem install from the command line to install a
I'm a newcomer trying to get my feet wet with Ruby and Sinatra. I
I have a Ruby on Rails app running on my server, and I can't
In Ruby, can I do something C-like, like this (with my made-up operator '&'):
i've developed small web app for personal use with Ruby on Rails. Now when
I do a fair bit of work at the command line. When I start
### Ruby 1.8.7 ### require 'rubygems' require 'oniguruma' # for look-behind Oniguruma::ORegexp.new('h(?=\w*)') # =>
Ruby's safe mode disallows the use of tainted data by potentially dangerous operations. It
Ruby Version Manager allows us to use an .rvmrc file in each project to

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.