Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
179 lines (112 sloc) 3.88 KB
.. author:: Theodor Müller <info@trilliarden.net>
.. tag:: lang-ruby
.. tag:: audience-developers

Logo

_static/images/puma.png

Puma

.. tag_list::

Puma is a Ruby web server built for speed and parallelism. It is designed for running Rack apps only. It is licensed under the BSD 3-Clause license. This guide explains how to install Puma and run a minimal, custom Ruby application.


Note

For this guide you should be familiar with the basic concepts of

Prerequisites

We're using Ruby in the stable version 2.5:

[isabell@stardust ~]$ uberspace tools version show ruby
Using 'Ruby' version: '2.5'
[isabell@stardust ~]$

If you want to use Puma with your own domain you need to setup your domain first:

Installation

Use gem to install the latest version of Puma:

[isabell@stardust ~]$ gem install puma
Fetching: puma-3.12.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed puma-3.12.0
1 gem installed
[isabell@stardust ~]$

Create a directory, and inside the directory a file rubyapp.ru for the application:

[isabell@stardust ~]$ mkdir ~/puma
[isabell@stardust ~]$ touch ~/puma/rubyapp.ru
[isabell@stardust ~]$

This file is the Rackup file for the application. Add the following content to ~/puma/rubyapp.ru, a simple Hello World application:

class HelloWorld
  def call(env)
    [200, {"Content-Type" => "text/plain"}, ["Hello World"]]
  end
end

run HelloWorld.new

Create the folder for logs:

[isabell@stardust ~]$ mkdir ~/logs/puma
[isabell@stardust ~]$

Configuration

Puma configuration file

Next, create a Puma configuration file:

[isabell@stardust ~]$ touch ~/puma/config.rb
[isabell@stardust ~]$

... and add the following content. Adapt the highlighted lines to your setup.

Setup supervisord

Create ~/etc/services.d/puma.ini with the following content. Adapt the highlighted lines to your setup.

The --config parameter provides the path to the configuration file.

Configure web server

Note

puma is running on port 9000.

Test

To validate the installation, open a browser and visit isabell.uber.space. If everything is set up correctly, you will see "Hello World".

Updates

Note

Check the update feed regularly to stay informed about the newest version.

Use gem to update Puma:

[isabell@stardust ~]$ gem update puma
(...)
[isabell@stardust ~]$

Further Reading


Tested with Puma 3.12, Uberspace 7.1.17

.. author_list::
You can’t perform that action at this time.