Sha256: f085bd2416d20d83ca5995ef81a753d7bf7f81a28cfbf8f2d08ac1f6d8117918
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 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) @daemon = Suj::Pusher::Daemon.new @daemon.start end def stop @daemon.stop end end redis_host = "localhost" redis_port = 6379 redis_db = 0 redis_namespace = "pusher" logdir = File.join(WORKDIR, "logs") piddir = File.join(WORKDIR, "pids") cerdir = File.join(WORKDIR, "certs") ARGV.options do |opts| opts.banner = BANNER opts.on('-H REDIS HOST', '--host REDIS HOST', String, 'Redis server to connect') { |host| redis_host = host } opts.on('-P REDIS PORT', '--port REDIS PORT', String, 'Redis server port') { |port| redis_port = port } opts.on('-b REDIS DB', '--db REDIS DB', String, 'Redis database number') { |db| redis_db = db } opts.on('-n REDIS NAMESPACE', '--namespace REDIS NAMESPACE', String, 'Redis server namespace') { |name| redis_namespace = name } opts.on('-l LOGS', '--logdir LOGS', String, 'Logs destination directory') { |l| logdir = l } opts.on('-p PIDS', '--piddir PIDS', String, 'Pids destination diercoty') { |pid| piddir = pid } opts.on('-c CERTS', '--cerdir CERTS', String, 'Directory to store certificates') { |cert| cerdir = cert } opts.on('-v', '--version', 'Print this version of pusher daemon.') { puts "rapns #{Suj::Pusher::VERSION}"; exit } opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit } opts.parse! end FileUtils.mkdir_p(cerdir) FileUtils.mkdir_p(logdir) FileUtils.mkdir_p(piddir) config = Suj::Pusher::Configuration.new config.certs_path = cerdir config.redis_host = redis_host config.redis_port = redis_port config.redis_db = redis_db config.redis_namespace = redis_namespace Suj::Pusher.config.update(config) PusherDaemon.spawn!( sync_log: true, working_dir: Dir.pwd, log_file: File.join(logdir, "pusher-worker.log"), pid_file: File.join(piddir, "pusher-worker.pid") )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
suj-pusher-0.1.5 | bin/pusher |