Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use systemd to start Puma #232

Merged
merged 3 commits into from
Nov 23, 2023
Merged

Use systemd to start Puma #232

merged 3 commits into from
Nov 23, 2023

Commits on Nov 23, 2023

  1. Use systemd to start Puma

    The `puma.service` file included here is an adaptation of the ERB
    template provided by the capistrano3-puma gem. In order to transition
    smoothly from the systemd configuration generated by this installer to
    the systemd configuration provided by capistrano3-puma, the
    `puma_service_unit_name` must be the same during both installation and
    deployment.
    
    Note that, now that Puma starts with systemd, we have to wait till it
    creates a socket before continuing; otherwise the socket file won't be
    there when we execute the next command, and that command will file.
    
    Also note we have to configure the XDG_RUNTIME_DIR variable. Quoting the
    ansible documentation [1]:
    
    > For systemd to work with ‘user’, the executing user must have its own
    > instance of dbus started and accessible (systemd requirement).
    >
    > The user dbus process is normally started during normal login, but not
    > during the run of Ansible tasks. Otherwise you will probably get a
    > 'Failed to connect to bus: no such file or directory' error.
    >
    > The user must have access, normally given via setting the
    > XDG_RUNTIME_DIR variable.
    
    We also need to check for systemd access because ansible doesn't do it
    automatically [2]. In order to allow unprivileged users to enable
    lingering to enable systemd user units, we need to install the
    policykit-1 package, which is installed by default in Ubuntu but not on
    Debian Bookworm. Without this package the action of lingering requires
    sudo priveleges.
    
    Finally, we're using Consul Democracy's `master` branch, since it
    contains support for Puma with Systemd.
    
    [1] https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_service_module.html#parameter-scope
    [2] See issue in 72674 https://github.com/ansible/ansible/issues/
    
    Co-Authored-By: Senén Rodero <[email protected]>
    javierm and Senen committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    659732c View commit details
    Browse the repository at this point in the history
  2. Modify the Puma command so it works with Ansible

    While this isn't needed when starting the Puma service on the server or
    with Capistrano, we need the RVM script while using the installer.
    
    The file is now different from the one generated by capistrano3-puma,
    but that's alright because it will be overwritten when deploying with
    Capistrano (as long as the `:puma_service_unit_name` is the same).
    javierm committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    480c7b1 View commit details
    Browse the repository at this point in the history
  3. Don't test systemd on Debian in Github Actions

    The Docker images for Debian don't include systemd and, even when using
    an image that comes with support with systemd [1], we're getting a
    warning when starting Puma (the following error takes place when we skip
    the "Enable systemd access" step, since that step also raises an error
    in Debian):
    
    > Warning: : daemon-reload failed, but target is a chroot or systemd
    > is offline.
    > Continuing. Error was: 1 / Failed to connect to bus: No such file or
    > directory
    > Warning: : Target is a chroot or systemd is offline. This can
    > lead to false positives or prevent the init system tools from working.
    
    So Puma isn't started in this case.
    
    So now Debian support is uncertain, since we aren't able to test that
    Puma starts correctly and the web is accessible. We're at least testing
    that the rest of the installation process runs correctly.
    
    [1] https://github.com/trfore/docker-debian11-systemd/blob/main/Dockerfile
    javierm committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    5af53dd View commit details
    Browse the repository at this point in the history