Hot deploy Ruby just like PHP: FTP upload file and

2019-05-18 19:00发布

问题:

Is it possible to hot deploy Ruby just like PHP? Normally I used FTP to upload the PHP file, then it will be available automatically. Can Ruby hot deploy its file like this?

Your comment welcome.

回答1:

Are you talking about a ruby on rails application ?

If so, when deploying a rails application in production mode, the all application gets loaded in memory. So changing the files won't affect the running application.

For hot restarting a rails application you will need to use solution such as:

  • Unicorn
  • Puma
  • Passenger

For a first time, Puma is the easiest way.

However if you are looking for a zero-downtime, either Unicorn or Passenger enterprise are what you are looking for.

EDIT

Unicorn

  • Free
  • Complex configuration
  • zero-downtime when hot restarting. when hot-restarting unicorn, it keeps the old threads working until the new ones are fully functionnal. So if the new ones fail to start, nothing happens. The old ones just keep going.

Puma

  • Free
  • Simple configuration
  • hot restart but no zero-downtime. When hot-restarting puma, it shuts down the old threads and starts the new ones. Puma keeps the sockets open, so the client are not disconnected, but are waiting to get a response while the new threads restart. However if the new threads fail to start, Puma can't restart the old ones. So connections are lost and the server is down.

Passenger

Free edition

  • Free
  • The configuration is easier than unicorn
  • hot-restart, but no zero-downtime. Like Puma.

Enterprise edition

  • $29/mo
  • The configuration is easier than unicorn
  • zero-downtime when hot restarting. Like Unicorn.