Sha256: 232313ddd41611d4ea018b04f178582680001cbfc808a8e3c56b9c4fbcdda852
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require 'webrtc-rails' namespace :webrtc_rails do desc 'Start webrtc daemon' task start: :environment do start end desc 'Stop webrtc daemon' task stop: :environment do stop end desc 'Restart webrtc daemon' task restart: :environment do stop start end desc 'Check the status of webrtc daemon' task status: :environment do status end @pid_file = "#{Rails.root}/tmp/pids/webrtc_rails.pid" def start if File.exists?(@pid_file) pid = File.read(@pid_file) begin if Process.kill(0, pid.to_i) puts 'webrtc daemon alrerady exists' return end rescue Errno::ESRCH end end puts 'webrtc daemon started' Process.daemon File.write(@pid_file, Process.pid.to_s) daemon = WebrtcRails::Daemon.new daemon.start end def stop unless File.exists?(@pid_file) puts 'webrtc daemon does not exist' return end pid = File.read(@pid_file) begin if Process.kill(:INT, pid.to_i) puts 'webrtc daemon stoped' File.delete(@pid_file) end rescue Errno::ESRCH puts 'webrtc daemon does not exist' end end def status unless File.exists?(@pid_file) puts 'webrtc daemon is not running' return end pid = File.read(@pid_file) begin if Process.kill(0, pid.to_i) puts 'webrtc daemon is running' end rescue Errno::ESRCH puts 'webrtc daemon is not running' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
webrtc-rails-0.3.3 | lib/tasks/webrtc_rails.rake |
webrtc-rails-0.3.2 | lib/tasks/webrtc_rails.rake |
webrtc-rails-0.3.1 | lib/tasks/webrtc_rails.rake |