asmodai 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -14
- data/asmodai.gemspec +1 -1
- data/lib/asmodai/cli.rb +11 -0
- data/lib/asmodai/generator/templates/Gemfile +1 -1
- data/lib/asmodai/generator/templates/init_d.erb +2 -2
- data/lib/asmodai/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -9,13 +9,12 @@ stop-scripts, pid-file logic or implementing logging.
|
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
$ gem install asmodai
|
12
|
+
$ gem install asmodai
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
$ asmodai new foobar
|
17
|
-
|
18
|
-
$ cd foobar
|
16
|
+
$ asmodai new foobar
|
17
|
+
$ cd foobar
|
19
18
|
|
20
19
|
Here you will find a dummy implementation:
|
21
20
|
|
@@ -38,28 +37,31 @@ Here you will find a dummy implementation:
|
|
38
37
|
|
39
38
|
You can develop your daemon by executing
|
40
39
|
|
41
|
-
$ asmodai foreground
|
40
|
+
$ asmodai foreground
|
42
41
|
|
43
42
|
This executes the daemon in the foreground and outputs all logging to standard
|
44
43
|
output. It can be terminated with Ctrl-C.
|
45
44
|
|
46
45
|
To start your daemon in the background run
|
47
46
|
|
48
|
-
$ asmodai start
|
47
|
+
$ asmodai start
|
48
|
+
|
49
|
+
This will redirect all the output from the process to log/foobar.log
|
49
50
|
|
50
|
-
|
51
|
+
In order to check the status of the daemon run
|
51
52
|
|
52
53
|
$ asmodai status
|
53
54
|
=> foobar runs with pid 75952
|
54
|
-
|
55
|
+
|
56
|
+
|
55
57
|
Stop the daemon
|
56
58
|
|
57
|
-
$ asmodai stop
|
59
|
+
$ asmodai stop
|
58
60
|
|
59
61
|
## Example: Using Asmodai with EventMachine
|
60
62
|
|
61
|
-
$ asmodai new echo
|
62
|
-
$ cd echo
|
63
|
+
$ asmodai new echo
|
64
|
+
$ cd echo
|
63
65
|
|
64
66
|
Edit the Gemfile
|
65
67
|
|
@@ -89,9 +91,7 @@ Edit echo.rb
|
|
89
91
|
|
90
92
|
class Echo < Asmodai::Daemon
|
91
93
|
require 'server' # lib is automatically added to the $LOAD_PATH
|
92
|
-
|
93
|
-
attr_accessor :running
|
94
|
-
|
94
|
+
|
95
95
|
def on_signal(sig)
|
96
96
|
EventMachine::stop_event_loop
|
97
97
|
end
|
@@ -103,6 +103,12 @@ Edit echo.rb
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
+
Now, run
|
107
|
+
|
108
|
+
$ bundle install
|
109
|
+
$ asmodai start
|
110
|
+
|
111
|
+
And you have your own running Echo server. Wheee!
|
106
112
|
|
107
113
|
|
108
114
|
|
data/asmodai.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Sebastian Morawietz"]
|
10
10
|
s.email = []
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/flitzwald/asmodai"
|
12
12
|
s.summary = "A simple daemon generator"
|
13
13
|
s.description = "A simple daemon generator"
|
14
14
|
|
data/lib/asmodai/cli.rb
CHANGED
@@ -22,14 +22,25 @@ class Asmodai::CLI < Thor
|
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "install", "Installs startup scripts to /etc/init.d"
|
25
|
+
method_option :rvm, :type => :boolean,
|
26
|
+
:desc => "Create an rvm-wrapper for asmodai"
|
25
27
|
method_option :autostart,
|
26
28
|
:type => :boolean,
|
27
29
|
:desc => %{If you provide this, startup-links will be generated for the given runlevel. This is currently only supported on Debian/Ubuntu.}
|
28
30
|
def install
|
29
31
|
@info = Asmodai::Info.current
|
32
|
+
@asmodai = "asmodai"
|
33
|
+
|
34
|
+
if options[:rvm]
|
35
|
+
wrapper_cmd="rvm wrapper #{ENV['rvm_ruby_string']} bootup asmodai"
|
36
|
+
@asmodai=`which bootup_asmodai`.strip
|
37
|
+
end
|
38
|
+
|
30
39
|
path = "/etc/init.d/#{@info.daemon_name}"
|
31
40
|
template "templates/init_d.erb", path
|
32
41
|
system "chmod a+x #{path}"
|
42
|
+
|
43
|
+
|
33
44
|
if options[:autostart]
|
34
45
|
if (update_bin=`which update-rc.d`.strip).blank?
|
35
46
|
warn "update-rc.d was not found. Omitting autostart installation."
|
@@ -16,12 +16,12 @@ SCRIPTNAME=/etc/init.d/$NAME
|
|
16
16
|
|
17
17
|
do_start()
|
18
18
|
{
|
19
|
-
sudo -u <%= @info.base_file_owner.name %> bash -l -c "cd <%= @info.path %> && asmodai start"
|
19
|
+
sudo -u <%= @info.base_file_owner.name %> bash -l -c "cd <%= @info.path %> && <%= @asmodai %> start"
|
20
20
|
}
|
21
21
|
|
22
22
|
do_stop()
|
23
23
|
{
|
24
|
-
sudo -u <%= @info.base_file_owner.name %> bash -l -c "cd <%= @info.path %> && asmodai stop"
|
24
|
+
sudo -u <%= @info.base_file_owner.name %> bash -l -c "cd <%= @info.path %> && <%= @asmodai %> stop"
|
25
25
|
|
26
26
|
return 0
|
27
27
|
}
|
data/lib/asmodai/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sebastian Morawietz
|
@@ -96,7 +96,7 @@ files:
|
|
96
96
|
- test/test_daemon/.gitignore
|
97
97
|
- test/test_helper.rb
|
98
98
|
has_rdoc: true
|
99
|
-
homepage:
|
99
|
+
homepage: https://github.com/flitzwald/asmodai
|
100
100
|
licenses: []
|
101
101
|
|
102
102
|
post_install_message:
|