-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathService.rb
40 lines (30 loc) · 878 Bytes
/
Service.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'Colorify'
# services are stuff like merb or mysql or memcached
# that might not necesarily be deployed every time
# we want to restart
class Service
include Colorify
def load
service = {}
puts colorBlack("creating a new service")
puts colorBlack("-------------------")
print colorBlack("Name: ")
service["name"] = STDIN.gets.chomp
print colorBlack("Start Cmd: ")
service["start"] = STDIN.gets.chomp
print colorBlack("Stop Cmd: ")
service["stop"] = STDIN.gets.chomp
hash = File.open('pac.yml') do |f| YAML.load f end
if hash.nil? or hash.eql? false then
hash = {}
end
if hash["services"].nil? then
services = {}
hash["services"] = services
end
hash["services"]["#{service["name"]}"] = service
File.open("pac.yml", 'w') do |f|
f.puts hash.to_yaml
end
end
end