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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:20:40+00:00 2026-05-27T02:20:40+00:00

I am developing a Rails v2.3 app. with MySQL v5.1 database on a Ubuntu

  • 0

I am developing a Rails v2.3 app. with MySQL v5.1 database on a Ubuntu machine.

I know the commands to start, stop Nginx and MySQL on command line.

But now, I need to have the following process defined in one of my rake task of my Rails app.:

stop Nginx --> stop(shut down) MySQL --> ... --> start MySQL --> start Nginx

Which means all these need to be defined in ruby script in a rake task of my Rails app.

I am not sure how to make ruby code run the above process(execute the commands) in my 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-05-27T02:20:41+00:00Added an answer on May 27, 2026 at 2:20 am

    Check out Ruby’s Kernel module (it’s built in). Using backticks, you can run the commands to stop/start nginx and MySQL, and even check their exit codes to make sure they executed properly (If your stop/start scripts support exit codes).

    Example:

    # In your Rakefile
    namespace :servers do
      task :stop do
        nginx_stop_output = `service nginx stop`
        if $?.exitstatus != 0
          # handle shutdown failure
        end
    
        mysql_stop_output = `service mysql stop`
        if $?.exitstatus != 0
          # handle shutdown failure
        end
      end
    
      task :start do
        nginx_start_output = `service nginx start`
        if $?.exitstatus != 0
          # handle startup failure
        end
    
        mysql_start_output = `service mysql start`
        if $?.exitstatus != 0
          # handle startup failure
        end
      end
    end
    

    Substitute in your own stop/start commands in the backticks.

    You can then run these tasks with rake servers:stop and rake servers:start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing Rails v2.3 app. and using MySQL v5.1 on Ubuntu machine. I
I am using MySQL v5.1. I am developing a Rails app. and writing a
I am developing a Rails app. after I execute a sql command like following:
I work on Ubuntu developing a Rails app for my church. We use a
I am developing a Rails app which should rely on existing database. There are
I'm developing a Rails 3 app on Ubuntu 11.04, and I get the following
I'm developing a Rails 3 app on Ubuntu 10.10 and need to check the
Hoping someone can help me out. If I'm developing a Rails 3 app, but
I am developing Rails v2.3 app. and using MySQL v5.1 . I need to
I've been trying to fix a bug in the Rails app I'm developing, and

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.