nand 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.ja.md +206 -0
- data/README.md +203 -0
- data/Rakefile +6 -0
- data/bin/console +12 -0
- data/bin/setup +7 -0
- data/exe/nand +19 -0
- data/lib/nand.rb +47 -0
- data/lib/nand/cli.rb +126 -0
- data/lib/nand/daemon.rb +127 -0
- data/lib/nand/launcher.rb +55 -0
- data/lib/nand/launcher/executable_file_launcher.rb +35 -0
- data/lib/nand/launcher/plugin_launcher.rb +29 -0
- data/lib/nand/launcher/rb_file_launcher.rb +63 -0
- data/lib/nand/launcher/shell_launcher.rb +25 -0
- data/lib/nand/logger.rb +42 -0
- data/lib/nand/plugin.rb +22 -0
- data/lib/nand/proc_operation.rb +47 -0
- data/lib/nand/util/object.rb +25 -0
- data/lib/nand/version.rb +5 -0
- data/nand.gemspec +31 -0
- data/samples/spec_mon.rb +67 -0
- data/spec/nand/cli_spec.rb +8 -0
- data/spec/nand/daemon_spec.rb +8 -0
- data/spec/nand/launcher/executable_file_launcher_spec.rb +8 -0
- data/spec/nand/launcher/plugin_launcher_spec.rb +8 -0
- data/spec/nand/launcher/rb_file_launcher_spec.rb +8 -0
- data/spec/nand/launcher/shell_launcher_spec.rb +8 -0
- data/spec/nand/launcher_spec.rb +8 -0
- data/spec/nand/logger_spec.rb +8 -0
- data/spec/nand/plugin_spec.rb +22 -0
- data/spec/nand/proc_operation_spec.rb +44 -0
- data/spec/nand/util/object_spec.rb +8 -0
- data/spec/nand/version_spec.rb +10 -0
- data/spec/nand_spec.rb +28 -0
- data/spec/spec_helper.rb +2 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64a59a5d1347cb4d11d48fa7224f8d9746039499
|
4
|
+
data.tar.gz: b891827552f927644004f4c16ede6999f067ab93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03e62874073a537cee92d16e052f7e233f1c4f9c74065cf440d90c1ae8b94019ece653997c2d697aa66c48d76fdf386c19d182d658e2a4020125b9112eac328e
|
7
|
+
data.tar.gz: eba2559e047d7af7a7c92ff1fb7cef052fcf1a27b650d126874d13d69779196737d2e7256b7751d9e18f53d3c6cf9ca9cb1e703db0dd21352dce026910ddb701
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 satoyama
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.ja.md
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
# Nand [![Gem Version](https://badge.fury.io/rb/nand.svg)](http://badge.fury.io/rb/nand) [![Code Climate](https://codeclimate.com/github/linkodehub/nand/badges/gpa.svg)](https://codeclimate.com/github/linkodehub/nand) [![Join the chat at https://gitter.im/linkodehub/nand](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/linkodehub/nand?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2
|
+
|
3
|
+
## 概要
|
4
|
+
|
5
|
+
Nand は Nandemo(ナンデモ) daemon にすることができるRubyで作られたシンプルなコマンドラインツールです。
|
6
|
+
|
7
|
+
ここで言う"ナンデモ"とは、シェルコマンドや実行形式のファイル、
|
8
|
+
Rubyファイル(ライブラリやnandのplugin)になります。
|
9
|
+
|
10
|
+
デーモン化するには、シンプルに `nand start TARGET`をコマンドラインから実行するだけです。
|
11
|
+
停止させるには、もちろん`nand stop TARGET`です。
|
12
|
+
動作状態の確認は`nand status TARGET`で確認できます。
|
13
|
+
|
14
|
+
## インストール
|
15
|
+
|
16
|
+
$ gem install nand
|
17
|
+
|
18
|
+
## 簡単な利用方法
|
19
|
+
|
20
|
+
### コマンド
|
21
|
+
|
22
|
+
$ nand SUB_COMMAND TARGET [オプション]
|
23
|
+
|
24
|
+
`SUB_COMMAND` と デーモンプロセスのターゲットを指定します。
|
25
|
+
|
26
|
+
### 起動
|
27
|
+
|
28
|
+
$ cd /any/path
|
29
|
+
$ nand start sleep 1000
|
30
|
+
sleep is Start Success [85596]
|
31
|
+
|
32
|
+
ターゲット以降で、Nandのオプションとして認識されないものは、
|
33
|
+
デーモンプロセスへ引き渡されます。
|
34
|
+
なお、`sleep 1000` がデーモンプロセスとして動作し、`sleep`がデーモンプロセス名としてnandに認識されます。
|
35
|
+
|
36
|
+
### 状態確認
|
37
|
+
|
38
|
+
ターゲット`sleep`の動作状況を確認するためには、以下のコマンドを実行します。
|
39
|
+
|
40
|
+
$ cd /any/path
|
41
|
+
$ nand status sleep
|
42
|
+
sleep is Running [85596] by USER in /any/path
|
43
|
+
|
44
|
+
`start`と同一ディレクトリであれば、デーモンプロセス名としての`sleep`は省略できます。
|
45
|
+
|
46
|
+
### 停止
|
47
|
+
|
48
|
+
$ nand stop sleep
|
49
|
+
sleep is Stopped [85596]
|
50
|
+
|
51
|
+
`stop`も`status`と同様に`start`と同一ディレクトリであれば、
|
52
|
+
デーモンプロセス名としての`sleep`は省略もできます。
|
53
|
+
|
54
|
+
$ nand status sleep
|
55
|
+
sleep is Not Running in /any/path
|
56
|
+
|
57
|
+
|
58
|
+
## Rubyファイルのデーモン化
|
59
|
+
|
60
|
+
カレントディレクトリに 以下の様な `forever_sleep.rb` というファイルが存在する場合
|
61
|
+
|
62
|
+
```ruby:forever_sleep.rb
|
63
|
+
require 'nand/plugin'
|
64
|
+
|
65
|
+
module Sample
|
66
|
+
class ForeverSleep
|
67
|
+
extend Plugin
|
68
|
+
def self.executor(*argv)
|
69
|
+
new(*argv)
|
70
|
+
end
|
71
|
+
def exec
|
72
|
+
sleep
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
$ nand start forever_sleep.rb -p Sample::ForeverSleep
|
79
|
+
forever_sleep.rb is Start Success [86326]
|
80
|
+
|
81
|
+
$ nand stop forever_sleep.rb
|
82
|
+
forever_sleep.rb is Stopped [86326]
|
83
|
+
|
84
|
+
実行可能ファイルでないRubyのファイルを指定する場合は、Nand::Pluginをextendしたクラスの
|
85
|
+
クラス名を`-p`オプションで指定する必要があります。
|
86
|
+
ただし、`-p`オプションが未指定の場合、ファイル名からからクラス名を類推しようとします。
|
87
|
+
この例の場合、
|
88
|
+
ファイル名が _forever_sleep.rb_ のため、`ForeverSleep` クラスとして検索します。
|
89
|
+
残念ながらこの例では、失敗します。
|
90
|
+
|
91
|
+
もし、上記のようなファイルをsample-VERSION.gemとしてインストールした場合は、
|
92
|
+
Rubyのファイル名ではなく、パッケージ名を指定することで、デーモン化できます。
|
93
|
+
ただし、Pluginファイルを指定されたディレクトリとファイル名で
|
94
|
+
(sample/nand/plugin.rb)配置する必要があります。
|
95
|
+
|
96
|
+
|
97
|
+
## 様々な利用方法
|
98
|
+
|
99
|
+
### Nandオプションと重複する場合
|
100
|
+
|
101
|
+
Nandオプションと重複する場合は、2通りの方法で回避できます。
|
102
|
+
|
103
|
+
一つめは、"や'(クォーテーション)でオプションを囲む方法
|
104
|
+
|
105
|
+
$ nand start any.sh "--run_dir /tmp"
|
106
|
+
|
107
|
+
なお、`"--run_dir /tmp"`は内部では `--run_dir`, `/tmp`に分割されますので、
|
108
|
+
分割されないようにするためには、`'"--run_dir /tmp"'`などのようにする必要があります。
|
109
|
+
|
110
|
+
二つめは 2つのダッシュ(--)の後に記述する方法
|
111
|
+
|
112
|
+
$ nand start any.sh -- --run_dir /tmp
|
113
|
+
|
114
|
+
これらの方法で、nandと重複するオプションを指定したターゲットに引き渡すことができます。
|
115
|
+
|
116
|
+
### デーモンプロセスへのパイプ
|
117
|
+
|
118
|
+
|
119
|
+
```sh
|
120
|
+
#!/bin/sh
|
121
|
+
sleep $1
|
122
|
+
echo $2
|
123
|
+
```
|
124
|
+
|
125
|
+
sleep_echo.shという実行形式のファイルがあった場合、
|
126
|
+
|
127
|
+
$ nand start sleep_echo.sh 100 '"foo bar baz"' --out out.log
|
128
|
+
|
129
|
+
$ cat out.log
|
130
|
+
foo bar baz
|
131
|
+
|
132
|
+
なお、STDINは`--in`、STDERRは `--err`にそれぞれパイプをつなぐことができます。
|
133
|
+
|
134
|
+
|
135
|
+
### 動作ディレクトリの変更
|
136
|
+
|
137
|
+
Nandにとって、動作ディレクトリは非常に重要です。
|
138
|
+
PIDファイルを出力したり、デーモンプロセスは動作ディレクトリに移動して動作します。
|
139
|
+
|
140
|
+
動作ディレクトリは基本的にnandコマンドを実行したディレクトリですが、
|
141
|
+
オプションで指定もできます。
|
142
|
+
|
143
|
+
$ nand start sleep_echo.sh 100 abc --run_dir /tmp --out out.log
|
144
|
+
|
145
|
+
これにより、`out.log`は`/tmp/out.log`に出力されます。
|
146
|
+
|
147
|
+
|
148
|
+
### 二重起動の禁止
|
149
|
+
|
150
|
+
原則として同じターゲットを指定して、デーモン化できません。
|
151
|
+
|
152
|
+
$ nand start sleep 1000
|
153
|
+
sleep is Start Success [97649]
|
154
|
+
$ nand start sleep 1000
|
155
|
+
sleep is Start Failed [PID file exist /any/path/.nand_sleep.pid]
|
156
|
+
|
157
|
+
これを回避する必要がある場合は、前述の動作ディレクトリを変更するか、
|
158
|
+
`-n` オプションを利用してデーモンプロセス名を指定する方法があります。
|
159
|
+
|
160
|
+
$ nand start sleep 1000 -n sleep1
|
161
|
+
sleep1 is Start Success [97649]
|
162
|
+
$ nand status
|
163
|
+
sleep is Running [97649] by USER in /run/dir
|
164
|
+
sleep1 is Running [97765] by USER in /run/dir
|
165
|
+
|
166
|
+
|
167
|
+
### 制限時間で自動停止させる
|
168
|
+
|
169
|
+
|
170
|
+
制限時間を秒で設けて、自動停止させることができます。
|
171
|
+
|
172
|
+
$ nand start vmstat 5 --sec 600
|
173
|
+
|
174
|
+
上記の例では、600秒後に自動で停止します。
|
175
|
+
|
176
|
+
### 自動再起動
|
177
|
+
|
178
|
+
デーモンプロセスが停止した場合、`-r` オプションを設定しておくことで、
|
179
|
+
自動で再起動させることができます。
|
180
|
+
|
181
|
+
$ nand start sleep 100 -r
|
182
|
+
|
183
|
+
この例では、100秒後に停止した`sleep 100`が、再度`sleep 100`で
|
184
|
+
再起動します。
|
185
|
+
|
186
|
+
## 注意事項
|
187
|
+
|
188
|
+
|
189
|
+
`stop`時はデーモンプロセスが管理するプロセスグループに対して、SIGTERMを送信します。
|
190
|
+
デーモンプロセスは送信したプロセスグループの終了を待ち合わせます。
|
191
|
+
デーモン化したい処理については、必ずSIGTERMで終了するようにしてください。
|
192
|
+
|
193
|
+
動作ディレクトリにおいて、`.nand_デーモンプロセス名.pid`というファイルが生成されます。
|
194
|
+
このファイルは二重起動抑制のために利用される他、`stop/status`時の
|
195
|
+
整合性確認にも利用されます。
|
196
|
+
もし、このファイルを誤って削除した場合は、`stop/status`がエラーを出力します。
|
197
|
+
その指示に従って、不要なプロセスであることをpsコマンドなどで確認して、
|
198
|
+
手動でプロセスを停止させてください。
|
199
|
+
|
200
|
+
## Contributing
|
201
|
+
|
202
|
+
1. Fork it
|
203
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
204
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
205
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
206
|
+
5. Create new Pull Request
|
data/README.md
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
# Nand [![Gem Version](https://badge.fury.io/rb/nand.svg)](http://badge.fury.io/rb/nand) [![Code Climate](https://codeclimate.com/github/linkodehub/nand/badges/gpa.svg)](https://codeclimate.com/github/linkodehub/nand) [![Join the chat at https://gitter.im/linkodehub/nand](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/linkodehub/nand?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2
|
+
|
3
|
+
### Overview
|
4
|
+
|
5
|
+
Nand is a simple CLI tool to make anything daemon by Ruby.
|
6
|
+
Nand is the meaning of Nandemo of Japanese.
|
7
|
+
|
8
|
+
Nandemo of here is a executable file and shell command, a non-executable Ruby file.
|
9
|
+
|
10
|
+
For starting daemonize TARGET, You can just type `nand start TARGET`.
|
11
|
+
You can stop by `nand stop TARGET`. `nand status TARGET` show it running status.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'nand'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install nand
|
26
|
+
|
27
|
+
## Easy Usage
|
28
|
+
|
29
|
+
### Command Definition
|
30
|
+
|
31
|
+
$ nand SUB_COMMAND TARGET [OPTION]
|
32
|
+
|
33
|
+
### Start
|
34
|
+
|
35
|
+
$ cd /any/path
|
36
|
+
$ nand start sleep 1000
|
37
|
+
sleep is Start Success [85596]
|
38
|
+
|
39
|
+
You can start TARGET by `start` SUB_COMMAND.
|
40
|
+
Though OPTION(s) after TARGET is Nand option, OPTION(s) Nand is unknown,
|
41
|
+
will be handed over to TARGET.
|
42
|
+
Here `1000` is handed over to `sleep`.
|
43
|
+
And Nand recognizes a shell command `sleep` as TARGET name.
|
44
|
+
When TARGET is success to be a daemon process, Nand show TARGET namd and daemon
|
45
|
+
process id.
|
46
|
+
|
47
|
+
### Status
|
48
|
+
|
49
|
+
For the TARGET `sleep` running status, Nand `status` command show running status.
|
50
|
+
|
51
|
+
$ cd /any/path
|
52
|
+
$ nand status sleep
|
53
|
+
sleep is Running [85596] by USER in /any/path
|
54
|
+
|
55
|
+
You can omit the TARGET name `sleep` because you stay in `/any/path`.
|
56
|
+
|
57
|
+
### Stop
|
58
|
+
|
59
|
+
Nand `stop` command stop daemon process with TARGET name.
|
60
|
+
|
61
|
+
$ nand stop sleep
|
62
|
+
sleep is Stopped [85596]
|
63
|
+
$ nand status sleep
|
64
|
+
sleep is Not Running in /any/path
|
65
|
+
|
66
|
+
You can also omit the TARGET name `sleep` as `status` because you stay in `/any/path`.
|
67
|
+
|
68
|
+
## A Ruby File
|
69
|
+
|
70
|
+
Following `forever_sleep.rb` in current directory, you can make it daemon with
|
71
|
+
file name as TARGET name.
|
72
|
+
|
73
|
+
```ruby:forever_sleep.rb
|
74
|
+
require 'nand/plugin'
|
75
|
+
|
76
|
+
module Sample
|
77
|
+
class ForeverSleep
|
78
|
+
extend Plugin
|
79
|
+
def self.executor(*argv)
|
80
|
+
new(*argv)
|
81
|
+
end
|
82
|
+
def exec
|
83
|
+
sleep
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
$ nand start forever_sleep.rb -p Sample::ForeverSleep
|
90
|
+
forever_sleep.rb is Start Success [86326]
|
91
|
+
|
92
|
+
$ nand stop forever_sleep.rb
|
93
|
+
forever_sleep.rb is Stopped [86326]
|
94
|
+
|
95
|
+
Nand can find the executor with exec method from defined class by `-p` option.
|
96
|
+
The class need to extend `Nand::Plugin`.
|
97
|
+
Then then executor can become a daemon process as TARGET name `forever_sleep.rb`.
|
98
|
+
|
99
|
+
## More Usage
|
100
|
+
|
101
|
+
### Avoid duplicated Nand Options
|
102
|
+
|
103
|
+
There are two ways to avoid duplicated Nand options for daemon's process options.
|
104
|
+
|
105
|
+
First, the options can be enclosed in "(double) or '(single) quatations.
|
106
|
+
|
107
|
+
$ nand start any.sh "--run_dir /tmp"
|
108
|
+
|
109
|
+
|
110
|
+
Others, you can put them after double dash(--).
|
111
|
+
|
112
|
+
$ nand start any.sh -- --run_dir /tmp
|
113
|
+
|
114
|
+
### Pipes to Daemon Process
|
115
|
+
|
116
|
+
You can pipe to daemon process STDOUT and STDERR, STDIN by using Nand options
|
117
|
+
`--out` and `--err`, `--in`.
|
118
|
+
|
119
|
+
Here is `sleep_echo.sh` as follows:
|
120
|
+
|
121
|
+
```sh
|
122
|
+
#!/bin/sh
|
123
|
+
sleep $1
|
124
|
+
echo $2
|
125
|
+
```
|
126
|
+
Then you can start with Nand pipe option.
|
127
|
+
|
128
|
+
$ nand start sleep_echo.sh 100 '"foo bar baz"' --out out.log
|
129
|
+
|
130
|
+
$ cat out.log
|
131
|
+
foo bar baz
|
132
|
+
|
133
|
+
### Running Directory
|
134
|
+
|
135
|
+
It is very important that you define the running directory with Nand option `--run_dir`.
|
136
|
+
A PID file is put in the running directory and daemon process change the running directory.
|
137
|
+
If you don't define the running directory, it is the current directory.
|
138
|
+
|
139
|
+
$ nand start sleep_echo.sh 100 abc --run_dir /tmp --out out.log
|
140
|
+
|
141
|
+
### Prohibition of Duplicated Start
|
142
|
+
|
143
|
+
Basically, you can not start duplicated daemon process name.
|
144
|
+
|
145
|
+
$ nand start sleep 1000
|
146
|
+
sleep is Start Success [97649]
|
147
|
+
$ nand start sleep 1000
|
148
|
+
sleep is Start Failed [PID file exist /any/path/.nand_sleep.pid]
|
149
|
+
|
150
|
+
If you would like to start duplicated daemon process name, you can
|
151
|
+
start in another run directory or as another daemon process name.
|
152
|
+
|
153
|
+
$ nand start sleep 1000 --run_dir /tmp
|
154
|
+
sleep1 is Start Success [97611]
|
155
|
+
$ nand start sleep 1000 -n sleep1
|
156
|
+
sleep1 is Start Success [97649]
|
157
|
+
$ nand status -a
|
158
|
+
sleep is Running [97649] by USER in /run/dir
|
159
|
+
sleep1 is Running [97765] by USER in /run/dir
|
160
|
+
sleep is Running [97611] by USER in /tmp
|
161
|
+
|
162
|
+
### Automatically Stop
|
163
|
+
|
164
|
+
Daemon process can automatically stop at the time limit, you defined.
|
165
|
+
|
166
|
+
$ nand start vmstat 5 --sec 600
|
167
|
+
|
168
|
+
Then `vmstat` will automatically stop after the lapse of 600 seconds.
|
169
|
+
|
170
|
+
### Automatically Recovery
|
171
|
+
|
172
|
+
If you defined Nand `-r` option, when the daemon process downed,
|
173
|
+
it would restart.
|
174
|
+
|
175
|
+
$ nand start sleep 100 -r
|
176
|
+
|
177
|
+
This `sleep 100` will be down after 100 seconds, then `sleep 100`
|
178
|
+
will restart soon.
|
179
|
+
|
180
|
+
|
181
|
+
## Note
|
182
|
+
|
183
|
+
When `nand stop`, Nand send signal(SIGTERM) to daemon process group, and
|
184
|
+
wait for termination of daemon process. Your daemon process finish by receiving
|
185
|
+
a SIGTERM.
|
186
|
+
|
187
|
+
You must not remove a PID file for Nand `.nand_[DAEMON_NAME].pid`.
|
188
|
+
It has be required to confirm integrity.
|
189
|
+
If you removed it, Nand output an error. Then you need to stop
|
190
|
+
the daemon process manually.
|
191
|
+
|
192
|
+
|
193
|
+
## Contributing
|
194
|
+
|
195
|
+
1. Fork it
|
196
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
197
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
198
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
199
|
+
5. Create new Pull Request
|
200
|
+
|
201
|
+
## License
|
202
|
+
|
203
|
+
MIT
|