0

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 Answer 1

0

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)

4
  • So many thanks, I added the ":" and started picking the port 80, however, the preceding variables are not taken into consideration, when I run curl 'localhost/api/v1/cowsay' I get __ | | -- \ ^__^ \ (oo)_______ (__)\ )\/\ ||----w | || ||
    – S.ELIAS
    Jul 8, 2020 at 10:50
  • please checkout: stackoverflow.com/help/someone-answers your comments sound more like new questions Jul 9, 2020 at 7:32
  • Sir, the question is related to the same file and app, if you look at it, the 1st 3 lines concern those I am talking about
    – S.ELIAS
    Jul 20, 2020 at 15:50
  • That does not really matter stackoverflow is not a discussion forum - but feel free to formulate your follow up questions as new questions Jul 23, 2020 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.