Sha256: b3b4e57de44013d8e83fa791fa5f1c397f03fd2ad016d9c11744124b91b79b8a

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module Neptuno
  module Overmind
    # Build docker container for Neptuno project
    class Start < Neptuno::CLI::Base
      include ::Neptuno::TTY::Config
      desc "Overmind: Start processes inside docker containers"

      option :all, type: :boolean, default: false, desc: "Run on all services"
      option :up, type: :boolean, default: true, desc: "Try to start containers before connecting"
      argument :services, type: :array, required: false, desc: "Optional list of services"

      def call(services: [], **options)
        command_services_to("start procs", all: options.fetch(:all), services_as_args: services) do |services|
          `neptuno up #{services.join(" ")}` if options.fetch(:up)

          services = services_with_procs.intersection(get_dependants(services).concat(services).uniq).sort
          puts "Starting processes on services: #{services.join(", ")}"

          if config.fetch("procfile_manager") == "tmux"
            services.each do |service|
              pid = spawn("cd #{neptuno_path} && tmuxinator start neptuno_#{service} #{service} -n #{service}",
                3 => "/dev/null")
              Process.detach(pid)
              puts "Neptuno started Tmux session for: #{service}" if `echo $TMUX`.strip.empty?
            end
          else
            services.each do |service|
              system("cd #{neptuno_path}/procfiles/#{service} && overmind start -D -N  #{if auto_restart_procs.to_a.size > 0
                                                                                           ("-r " + auto_restart_procs.join(",") + " ")
                                                                                         end} > /dev/null 2>&1")
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neptuno-1.5.0 lib/neptuno/overmind/start.rb
neptuno-1.4.10 lib/neptuno/overmind/start.rb
neptuno-1.2.1 lib/neptuno/overmind/start.rb
neptuno-1.2.0 lib/neptuno/overmind/start.rb