dyn-ruby-launchctl 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dyn-daemon +38 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7bf1cc2e0dc0245cbdf517893520740041b776c
4
- data.tar.gz: b9bcc0fa115cf31ce9718889e61baaa02519f6ac
3
+ metadata.gz: 6d9b002966c0493456e50e09bab77861905543f5
4
+ data.tar.gz: 75f2ac70f5bde2226d9830bc0fde4929d487fa4f
5
5
  SHA512:
6
- metadata.gz: 66b6433dbc685c0d572459e1f407b56178259350e56007f512e1f020b354ffbb32608491f0da836690af468a5d7a189e616c5ab17c86500be7fe56677fb59a23
7
- data.tar.gz: 573e6854a43716ee48a2fee670d6747828e2dc7a429006066d9475ed7397c014992687aba2009127a191f7caa68eaab689fe805d146cfd6c333bdd04200f5adf
6
+ metadata.gz: 84959ec417c27e22d5ecd412ef6e96b7de6ec7bc31f566d34aee2ad2094175d5a816aa44386c88be47434aa1911a2ee8a0ab3336c015788701bd83c81f0aa7e0
7
+ data.tar.gz: b95b09679e7a2474db6cf45df752463172f6efd6f1ddf50890220c33b95c26b5f8f146278a1a67056296849f97f46b2402773b5361682ad1497a345a63536756
data/bin/dyn-daemon CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "fileutils"
3
- SRV=ARGV[0].strip
4
- exit! unless ["srv","dyntask","help","path","status"].include? SRV
3
+ SRV=(ARGV[0] || "help").strip
4
+ exit! unless ["srv","dyntask","help","path","status","list"].include? SRV
5
5
  CMD={ "srv" => "dyn-srv", "dyntask" => "dyntask-server"}[SRV]
6
6
  if CMD
7
7
  FileUtils.mkdir_p File.join(ENV["HOME"],"dyndoc","log")
8
- DYN_DAEMON_ERR_FILE = File.join(ENV["HOME"],"dyndoc","log","launchctl_")+CMD+".err"
9
- DYN_DAEMON_OUT_FILE = File.join(ENV["HOME"],"dyndoc","log","launchctl_")+CMD+".out"
8
+ DYN_DAEMON_ERR_FILE = File.join(ENV["HOME"],"dyndoc","log","")+CMD+".log"
9
+ DYN_DAEMON_OUT_FILE = File.join(ENV["HOME"],"dyndoc","log","")+CMD+".out"
10
10
  end
11
11
 
12
12
  unless RUBY_PLATFORM =~ /darwin/
@@ -21,10 +21,11 @@ Service helpers to launch dyn-srv or dyntask service.
21
21
  Usage:
22
22
  dyn-daemon srv|dyntask new|load => create when not existing the dyntask service
23
23
  dyn-daemon srv|dyntask delete|unload => unload existing service
24
- dyn-daemon srv|dyntask start/stop => start/stop the dyntask service
24
+ dyn-daemon srv|dyntask start/stop => start/stop the service
25
25
  dyn-daemon srv|dyntask log => to watch log files
26
26
 
27
- dyn-daemon status|list => status of dyntask service
27
+ dyn-daemon status => status of dyntask service
28
+ dyn-daemon list => wrapper of 'launchctl list'
28
29
  dyn-daemon path get|set => set PATH env to $PATH
29
30
  DOC
30
31
  when "path"
@@ -35,8 +36,25 @@ when "path"
35
36
  elsif mode=="set"
36
37
  `launchctl setenv PATH $PATH`
37
38
  end
38
- when "status", "list"
39
+ when "list"
39
40
  puts `launchctl list | grep dyn`
41
+ when "status"
42
+ res=["dyn-srv","dyntask-server"].map do |cmd|
43
+ tmp=`launchctl list | grep #{cmd}`.strip
44
+ if tmp.empty?
45
+ "Not loaded"
46
+ else
47
+ tmp=tmp.split(" ")
48
+ if tmp[0]=="-"
49
+ "Stopped"
50
+ elsif tmp[1]=="-"
51
+ "Running"
52
+ else
53
+ "Unknown"
54
+ end
55
+ end
56
+ end.join("|")
57
+ puts res
40
58
  else
41
59
  dyn_plist=File.expand_path("~/Library/LaunchAgents/#{CMD}.plist")
42
60
  mode=ARGV[1]
@@ -75,7 +93,7 @@ else
75
93
  end
76
94
  `launchctl load #{dyn_plist}`
77
95
  when "unload","delete"
78
- if File.exists? dyn_srv_plist
96
+ if File.exists? dyn_plist
79
97
  `launchctl unload #{dyn_plist}`
80
98
  else
81
99
  puts "Service #{CMD} not available. Create it first: dyn-daemon #{SRV} new"
@@ -87,5 +105,17 @@ else
87
105
  puts File.read(DYN_DAEMON_ERR_FILE)
88
106
  puts "Out:"
89
107
  puts File.read(DYN_DAEMON_OUT_FILE)
108
+ when "status"
109
+ tmp=`launchctl list | grep #{CMD}`.strip
110
+ if tmp.empty?
111
+ puts "Not loaded"
112
+ else
113
+ tmp=tmp.split(" ")
114
+ if tmp[0]=="-"
115
+ puts "Stopped"
116
+ elsif tmp[1]=="-"
117
+ puts "Running"
118
+ end
119
+ end
90
120
  end
91
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyn-ruby-launchctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Managing dyn daemon.