Sha256: e1b1e97bcaccd3329959780453dee5ef23fe99a9e5a12c0cc6c9bbf9486b9581

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'suj/pusher'
require 'fileutils'
require 'daemon_spawn'


BANNER = "Usage: pusher start|stop|restart|status [options]"
WORKDIR = Dir.pwd

class PusherDaemon < DaemonSpawn::Base
  def start(args)
    config = Suj::Pusher::Configuration.new
    args.options do |opts|
      opts.banner = BANNER
      opts.on('-r REDIS', '--redis REDIS', String, 'Redis server to connect') { |redis| config.redis = redis }
      opts.on('-v', '--version', 'Print this version of rapns.') { puts "rapns #{Suj::Pusher::VERSION}"; exit }
      opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
      opts.parse!
    end

    config.certs_path = File.join(WORKDIR, "certs")
    FileUtils.mkdir_p(config.certs_path)
    FileUtils.mkdir_p(File.join(WORKDIR, "logs"))
    FileUtils.mkdir_p(File.join(WORKDIR, "tmp/pids"))
    Suj::Pusher.config.update(config)

    @daemon = Suj::Pusher::Daemon.new
    @daemon.start
  end

  def stop
    @daemon.stop
  end
end

PusherDaemon.spawn!(
  sync_log: true,
  working_dir: Dir.pwd
)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suj-pusher-0.1.0 bin/pusher
suj-pusher-0.0.1 bin/pusher