sinatra v1.4.8 not picking right port from config

100 Views Asked by At

I am following a course around Puppet. The instructor sets up an application machine (fedora 31) installing the following

cowsay pasture thin sinatra......

I am really new to this and have no idea but Ok they work fine. The instructor suggest creating a service for pasture, so 2 files need to be created , 1st one

vim /etc/pasture_config.yaml

---
default_character: stegosaurus
default_message: Hello From Sierac
db: postgres://pasture:jura551c@myip/pasturedb
sinatra_settings:
  :port: 80
  :server: thin

The 2nd file is /etc/systemd/system/pasture.service with the following content

[Unit]
Description=Run the pasture service

[Service]
Environmenti=RACK_ENV-production
ExecStart=/usr/local/bin/pasture start --config_file /etc/pasture_config.yaml

[Install]
WantedBy=multi-user.target

When I run the service pasture.service, in the log it shows that Sinatra did not pick the right port 80, I tried another port it was the same result, here is the output when I run the service

sudo systemctl status pasture.service ● pasture.service - Run the pasture service Loaded: loaded (/etc/systemd/system/pasture.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2020-06-27 22:14:37 CEST; 7s ago Main PID: 1329023 (ruby-mri) Tasks: 1 (limit: 4610) Memory: 32.2M CGroup: /system.slice/pasture.service └─1329023 /usr/bin/ruby-mri /usr/local/bin/pasture start --config_file /etc/pasture_config.yaml

Jun 27 22:14:37 puppetmaster29 systemd[1]: Started Run the pasture service. Jun 27 22:14:38 puppetmaster29 pasture[1329023]: == Sinatra (v1.4.8) has taken the stage on 4567 for development with backup from Thin

As you can notice that Sinatra does not pick the port I indicated in the config file but rather it uses the default port 4567.

What is missing

1

There are 1 best solutions below

4
Sir l33tname On

If you take a look at the pasture file

Pasture::API.set :pasture_options, options
if options[:sinatra_settings]
    Pasture::API.set options[:sinatra_settings]
    if Pasture::API.server == 'thin' || Pasture::API.server == 'mongrel'
        require Pasture::API.server
    end
end

https://github.com/puppetlabs/pltraining-pasture/blob/master/bin/pasture#L23

You see that the key should be :sinatra_settings. Your config file is missing a :.

(Another thing is your service file has a i too much in Environmenti but this does not mater for this issue)