Coder Social home page Coder Social logo

mina-deploy / mina-version_managers Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 17 KB

Mina plugin for version manager tasks

Home Page: https://rubygems.org/gems/mina-version_managers

License: MIT License

Ruby 99.22% Shell 0.78%
chruby mina plugin rbenv ruby rvm ry

mina-version_managers's People

Contributors

lovro-bikic avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

isabella232

mina-version_managers's Issues

Abstraction to run the ruby/node interpreter via the version manager

Hello,

I'd like to request some kind of abstraction to execute the right interpreter server-side.

The problem I'm trying to fix is the following (from one of my current projects):

namespace :systemd do
  set :service_name, -> { fetch(:application_name) }

  desc 'Install systemd unit'
  task :setup do
    command %{mkdir -p "$HOME/.config/systemd/user"}

  end
    unit_file = <<-UNIT.gsub(/^ {6}/, '').strip
      [Unit]
      Description=Rails application server: #{fetch(:service_name)}
      After=network.target

      [Service]
      Type=simple
      Environment=RAILS_ENV=#{fetch(:rails_env)}
      EnvironmentFile=-#{fetch(:shared_path)}/.env
      WorkingDirectory=#{fetch(:current_path)}
      ExecStart=-/usr/bin/env #{'rbenv exec ' if fetch(:rbenv_path)}bundle exec puma --bind "unix://#{fetch(:shared_path)}/tmp/sockets/puma.sock" --config "#{fetch(:current_path)}/config/puma.rb" --control-url "unix://#{fetch(:shared_path)}/tmp/sockets/pumactl.sock" --pidfile "#{fetch(:shared_path)}/tmp/pids/puma.pid" --state "#{fetch(:shared_path)}/tmp/sockets/puma.state" --quiet
      Restart=always
      SyslogIdentifier=#{fetch(:service_name)}

      [Install]
      WantedBy=multi-user.target
    UNIT

    command %{echo #{Shellwords.escape(unit_file)} > "$HOME/.config/systemd/user/#{fetch(:service_name)}.service"}

    command %{systemctl --user daemon-reload}
    command %{systemctl --user enable #{fetch(:service_name)}.service}
  end

In case anyone's wondering: this unit doesn't use Type=notify or socket activation because of incompatibility with JRuby.

As you can tell, I had to hack around to ensure the ExecStart command line ends up being something like:

ExecStart=-/usr/bin/env rbenv exec bundle exec puma <bunch of options>

If I switch to another version manager, I would have to rewrite this too. It'd be nice if I could write:

ExecStart=-#{fetch(:ruby_prefix)} puma <bunch of options>" 

…and that this would automatically work for rbenv, chruby, asdf, …

In addition:

  • there should be a similar abstraction for node instead of ruby.
  • there should (maybe) be something similar for bundler, yarn, npx, etc.

Thanks for your consideration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.