erlnixify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/CONTRIBUTING.md +139 -0
- data/Gemfile +4 -0
- data/LICENSE.md +194 -0
- data/README.md +226 -0
- data/Rakefile +22 -0
- data/erlnixify.gemspec +35 -0
- data/features/node.feature +35 -0
- data/features/settings.feature +20 -0
- data/features/step_definitions/node_steps.rb +108 -0
- data/features/step_definitions/settings_steps.rb +63 -0
- data/features/test_data/settings_config.yml +7 -0
- data/lib/erlnixify/exceptions.rb +6 -0
- data/lib/erlnixify/node.rb +135 -0
- data/lib/erlnixify/opts.rb +45 -0
- data/lib/erlnixify/settings.rb +127 -0
- data/lib/erlnixify/version.rb +3 -0
- data/lib/erlnixify.rb +24 -0
- data/reek.yml +8 -0
- data/settings.feature +20 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjRmMzY3YmU4NDA2MDMxZjgyMWQ3OWFlZTRiZmNmMDQwNDdiMjAzNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzgxZTQ3OWU5MGExNGZkM2U2ODY4ZGNmOWY2Yjk1OTJhZTJkNzlkNg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjBiYzEyZDYyZjc2ZDY5ZGMwMGEwOTUwMzAyYTBjNTVmMTc1M2I1ZWEyZjhh
|
10
|
+
OTdmOTg5NzJmM2Q2NGE4MjJlNDlhYjFlN2UwNzBjOTgyOWE4NjQwZjBkZmZk
|
11
|
+
MTE3ZjE1YTJiZDk0NzJhN2IyYTIzM2UwNjY2YzBjMjdmY2U4MWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTI3ZmNiMmQ1YmQ0NjYwYTU5NzI4ZjZkNDE4YjU4OTQyNDA4NDVkMDE5YTdi
|
14
|
+
MWE5NTMwMmJjOTgyOTQxZmE1NWE0MjFkZWE2ZThkZDNiMWU4ZTlkZGYxZDBi
|
15
|
+
OTYwOWUzODllMTk5YjEyZTQ1MWVlN2Q0ZWU5YTQ2ODA0NGM2MDg=
|
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
Contributing
|
2
|
+
============
|
3
|
+
|
4
|
+
Introduction
|
5
|
+
------------
|
6
|
+
|
7
|
+
This document describes the usages and rules to follow when contributing
|
8
|
+
to this project.
|
9
|
+
|
10
|
+
It uses the uppercase keywords SHOULD for optional but highly recommended
|
11
|
+
conditions and MUST for required conditions.
|
12
|
+
|
13
|
+
`git` is a distributed source code versioning system. This document refers
|
14
|
+
to three different repositories hosting the source code of the project.
|
15
|
+
`Your local copy` refers to the copy of the repository that you have on
|
16
|
+
your computer. The remote repository `origin` refers to your fork of the
|
17
|
+
project's repository that you can find in your GitHub account. The remote
|
18
|
+
repository `upstream` refers to the official repository for this project.
|
19
|
+
|
20
|
+
Reporting bugs
|
21
|
+
--------------
|
22
|
+
|
23
|
+
Upon identifying a bug you SHOULD submit a ticket, regardless of your
|
24
|
+
plan for fixing it. If you plan to fix the bug, you SHOULD discuss your
|
25
|
+
plans to avoid having your work rejected.
|
26
|
+
|
27
|
+
Before implementing a new feature, you SHOULD submit a ticket for discussion
|
28
|
+
on your plans. The feature might have been rejected already, or the
|
29
|
+
implementation might already be decided.
|
30
|
+
|
31
|
+
Cloning
|
32
|
+
-------
|
33
|
+
|
34
|
+
You MUST fork the project's repository to your GitHub account by clicking
|
35
|
+
on the `Fork` button.
|
36
|
+
|
37
|
+
Then, from your fork's page, copy the `Git Read-Only` URL to your clipboard.
|
38
|
+
You MUST perform the following commands in the folder you choose, replacing
|
39
|
+
`$URL` by the URL you just copied, `$UPSTREAM_URL` by the `Git Read-Only`
|
40
|
+
project of the official repository, and `$PROJECT` by the name of this project.
|
41
|
+
|
42
|
+
``` bash
|
43
|
+
$ git clone "$URL"
|
44
|
+
$ cd $PROJECT
|
45
|
+
$ git remote add upstream $UPSTREAM_URL
|
46
|
+
```
|
47
|
+
|
48
|
+
Branching
|
49
|
+
---------
|
50
|
+
|
51
|
+
Before starting working on the code, you MUST update to `upstream`. The
|
52
|
+
project is always evolving, and as such you SHOULD always strive to keep
|
53
|
+
up to date when submitting patches to make sure they can be merged without
|
54
|
+
conflicts.
|
55
|
+
|
56
|
+
To update the current branch to `upstream`, you can use the following commands.
|
57
|
+
|
58
|
+
``` bash
|
59
|
+
$ git fetch upstream
|
60
|
+
$ git rebase upstream/master
|
61
|
+
```
|
62
|
+
|
63
|
+
It may ask you to stash your changes, in which case you stash with:
|
64
|
+
|
65
|
+
``` bash
|
66
|
+
$ git stash
|
67
|
+
```
|
68
|
+
|
69
|
+
And put your changes back in with:
|
70
|
+
|
71
|
+
``` bash
|
72
|
+
$ git stash pop
|
73
|
+
```
|
74
|
+
|
75
|
+
You SHOULD use these commands both before working on your patch and before
|
76
|
+
submitting the pull request. If conflicts arise it is your responsability
|
77
|
+
to deal with them.
|
78
|
+
|
79
|
+
You MUST create a new branch for your work. First make sure you have
|
80
|
+
'fetched' `master`
|
81
|
+
|
82
|
+
``` bash
|
83
|
+
$ git checkout -b $BRANCH upstream/master
|
84
|
+
```
|
85
|
+
|
86
|
+
You MUST use a an insightful branch name.
|
87
|
+
|
88
|
+
If you later need to switch back to an existing branch `$BRANCH`, you can use:
|
89
|
+
|
90
|
+
``` bash
|
91
|
+
$ git checkout $BRANCH
|
92
|
+
```
|
93
|
+
|
94
|
+
Source editing
|
95
|
+
--------------
|
96
|
+
|
97
|
+
The following rules MUST be followed:
|
98
|
+
* Indentation uses 4 horizontal spaces
|
99
|
+
* Tabs should not be used
|
100
|
+
* Do NOT align code; only indentation is allowed
|
101
|
+
|
102
|
+
|
103
|
+
The following rules SHOULD be followed:
|
104
|
+
* Write small functions whenever possible
|
105
|
+
* Avoid having too many clauses containing clauses containing clauses
|
106
|
+
* Lines SHOULD NOT span more than 80 columns
|
107
|
+
|
108
|
+
When in doubt indentation as performed in the Erlang Emacs Mode is
|
109
|
+
correct.
|
110
|
+
|
111
|
+
Committing
|
112
|
+
----------
|
113
|
+
|
114
|
+
You MUST ensure that all commits pass all tests and do not have extra
|
115
|
+
Dialyzer warnings.
|
116
|
+
|
117
|
+
You MUST put all the related work in a single commit. Fixing a bug is one
|
118
|
+
commit, adding a feature is one commit, adding two features is two commits.
|
119
|
+
|
120
|
+
You MUST write a proper commit title and message. The commit title MUST be
|
121
|
+
at most 72 characters; it is the first line of the commit text. The second
|
122
|
+
line of the commit text MUST be left blank. The third line and beyond is the
|
123
|
+
commit message. You SHOULD write a commit message. If you do, you MUST make
|
124
|
+
all lines smaller than 80 characters. You SHOULD explain what the commit
|
125
|
+
does, what references you used and any other information that helps
|
126
|
+
understanding your work.
|
127
|
+
|
128
|
+
Submitting the pull request
|
129
|
+
---------------------------
|
130
|
+
|
131
|
+
You MUST push your branch `$BRANCH` to GitHub, using the following command:
|
132
|
+
|
133
|
+
``` bash
|
134
|
+
$ git push origin $BRANCH
|
135
|
+
```
|
136
|
+
|
137
|
+
You MUST then submit the pull request by using the GitHub interface to
|
138
|
+
the `master` branch. You SHOULD provide an explanatory message and refer
|
139
|
+
to any previous ticket related to this patch.
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
Apache License
|
2
|
+
==============
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
------------------------------------------------------------
|
8
|
+
|
9
|
+
1. Definitions.
|
10
|
+
|
11
|
+
"License" shall mean the terms and conditions for use,
|
12
|
+
reproduction, and distribution as defined by Sections 1 through 9
|
13
|
+
of this document.
|
14
|
+
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
16
|
+
the copyright owner that is granting the License.
|
17
|
+
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
19
|
+
other entities that control, are controlled by, or are under common
|
20
|
+
control with that entity. For the purposes of this definition,
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
22
|
+
direction or management of such entity, whether by contract or
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
25
|
+
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
27
|
+
exercising permissions granted by this License.
|
28
|
+
|
29
|
+
"Source" form shall mean the preferred form for making
|
30
|
+
modifications, including but not limited to software source code,
|
31
|
+
documentation source, and configuration files.
|
32
|
+
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
34
|
+
transformation or translation of a Source form, including but not
|
35
|
+
limited to compiled object code, generated documentation, and
|
36
|
+
conversions to other media types.
|
37
|
+
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
39
|
+
Object form, made available under the License, as indicated by a
|
40
|
+
copyright notice that is included in or attached to the work (an
|
41
|
+
example is provided in the Appendix below).
|
42
|
+
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
45
|
+
editorial revisions, annotations, elaborations, or other
|
46
|
+
modifications represent, as a whole, an original work of
|
47
|
+
authorship. For the purposes of this License, Derivative Works
|
48
|
+
shall not include works that remain separable from, or merely link
|
49
|
+
(or bind by name) to the interfaces of, the Work and Derivative
|
50
|
+
Works thereof.
|
51
|
+
|
52
|
+
"Contribution" shall mean any work of authorship, including the
|
53
|
+
original version of the Work and any modifications or additions to
|
54
|
+
that Work or Derivative Works thereof, that is intentionally
|
55
|
+
submitted to Licensor for inclusion in the Work by the copyright
|
56
|
+
owner or by an individual or Legal Entity authorized to submit on
|
57
|
+
behalf of the copyright owner. For the purposes of this definition,
|
58
|
+
"submitted" means any form of electronic, verbal, or written
|
59
|
+
communication sent to the Licensor or its representatives,
|
60
|
+
including but not limited to communication on electronic mailing
|
61
|
+
lists, source code control systems, and issue tracking systems that
|
62
|
+
are managed by, or on behalf of, the Licensor for the purpose of
|
63
|
+
discussing and improving the Work, but excluding communication that
|
64
|
+
is conspicuously marked or otherwise designated in writing by the
|
65
|
+
copyright owner as "Not a Contribution."
|
66
|
+
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal
|
68
|
+
Entity on behalf of whom a Contribution has been received by
|
69
|
+
Licensor and subsequently incorporated within the Work.
|
70
|
+
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
77
|
+
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
81
|
+
(except as stated in this section) patent license to make, have
|
82
|
+
made, use, offer to sell, sell, import, and otherwise transfer the
|
83
|
+
Work, where such license applies only to those patent claims
|
84
|
+
licensable by such Contributor that are necessarily infringed by
|
85
|
+
their Contribution(s) alone or by combination of their
|
86
|
+
Contribution(s) with the Work to which such Contribution(s) was
|
87
|
+
submitted. If You institute patent litigation against any entity
|
88
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging
|
89
|
+
that the Work or a Contribution incorporated within the Work
|
90
|
+
constitutes direct or contributory patent infringement, then any
|
91
|
+
patent licenses granted to You under this License for that Work
|
92
|
+
shall terminate as of the date such litigation is filed.
|
93
|
+
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the Work
|
95
|
+
or Derivative Works thereof in any medium, with or without
|
96
|
+
modifications, and in Source or Object form, provided that You meet
|
97
|
+
the following conditions:
|
98
|
+
|
99
|
+
(a) You must give any other recipients of the Work or Derivative
|
100
|
+
Works a copy of this License; and
|
101
|
+
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
103
|
+
stating that You changed the files; and
|
104
|
+
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
106
|
+
You distribute, all copyright, patent, trademark, and
|
107
|
+
attribution notices from the Source form of the Work, excluding
|
108
|
+
those notices that do not pertain to any part of the Derivative
|
109
|
+
Works; and
|
110
|
+
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
113
|
+
include a readable copy of the attribution notices contained
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
115
|
+
pertain to any part of the Derivative Works, in at least one of
|
116
|
+
the following places: within a NOTICE text file distributed as
|
117
|
+
part of the Derivative Works; within the Source form or
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
119
|
+
within a display generated by the Derivative Works, if and
|
120
|
+
wherever such third-party notices normally appear. The contents
|
121
|
+
of the NOTICE file are for informational purposes only and do
|
122
|
+
not modify the License. You may add Your own attribution notices
|
123
|
+
within Derivative Works that You distribute, alongside or as an
|
124
|
+
addendum to the NOTICE text from the Work, provided that such
|
125
|
+
additional attribution notices cannot be construed as modifying
|
126
|
+
the License.
|
127
|
+
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
129
|
+
may provide additional or different license terms and conditions
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
133
|
+
the conditions stated in this License.
|
134
|
+
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
138
|
+
this License, without any additional terms or conditions.
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
140
|
+
the terms of any separate license agreement you may have executed
|
141
|
+
with Licensor regarding such Contributions.
|
142
|
+
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
145
|
+
except as required for reasonable and customary use in describing
|
146
|
+
the origin of the Work and reproducing the content of the NOTICE
|
147
|
+
file.
|
148
|
+
|
149
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
150
|
+
to in writing, Licensor provides the Work (and each Contributor
|
151
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
152
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
153
|
+
without limitation, any warranties or conditions of TITLE,
|
154
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
155
|
+
PURPOSE. You are solely responsible for determining the
|
156
|
+
appropriateness of using or redistributing the Work and assume any
|
157
|
+
risks associated with Your exercise of permissions under this
|
158
|
+
License.
|
159
|
+
|
160
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
161
|
+
whether in tort (including negligence), contract, or otherwise,
|
162
|
+
unless required by applicable law (such as deliberate and grossly
|
163
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
164
|
+
liable to You for damages, including any direct, indirect, special,
|
165
|
+
incidental, or consequential damages of any character arising as a
|
166
|
+
result of this License or out of the use or inability to use the
|
167
|
+
Work (including but not limited to damages for loss of goodwill,
|
168
|
+
work stoppage, computer failure or malfunction, or any and all
|
169
|
+
other commercial damages or losses), even if such Contributor has
|
170
|
+
been advised of the possibility of such damages.
|
171
|
+
|
172
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
173
|
+
the Work or Derivative Works thereof, You may choose to offer, and
|
174
|
+
charge a fee for, acceptance of support, warranty, indemnity, or
|
175
|
+
other liability obligations and/or rights consistent with this
|
176
|
+
License. However, in accepting such obligations, You may act only
|
177
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
178
|
+
of any other Contributor, and only if You agree to indemnify,
|
179
|
+
defend, and hold each Contributor harmless for any liability
|
180
|
+
incurred by, or claims asserted against, such Contributor by reason
|
181
|
+
of your accepting any such warranty or additional liability.
|
182
|
+
|
183
|
+
END OF TERMS AND CONDITIONS
|
184
|
+
|
185
|
+
APPENDIX: How to apply the Apache License to your work.
|
186
|
+
|
187
|
+
To apply the Apache License to your work, attach the following
|
188
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
189
|
+
replaced with your own identifying information. (Don't include
|
190
|
+
the brackets!) The text should be enclosed in the appropriate
|
191
|
+
comment syntax for the file format. We also recommend that a
|
192
|
+
file or class name and description of purpose be included on the
|
193
|
+
same "printed page" as the copyright notice for easier
|
194
|
+
identification within third-party archives.
|
data/README.md
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
Erlnixify
|
2
|
+
=========
|
3
|
+
|
4
|
+
Erlang has the problem that it does not integrate nicely with
|
5
|
+
Unix-like systems. It can not be put under things like
|
6
|
+
deamon-tools. You can't trap signals and respond appropriately,
|
7
|
+
etc. This is a small ruby program that serves as a 'front' to an
|
8
|
+
Erlang node. It allows a system like `init.d` or `daemontools` to
|
9
|
+
manage Erlnixify and Erlnixify will in-turn manage the Erlang node
|
10
|
+
using standard OTP inputs.
|
11
|
+
|
12
|
+
For example, when Erlnixify recieves a SIGTERM signal, it will call
|
13
|
+
`init:stop()` on the Erlang node. This allows Erlang's release handler
|
14
|
+
to do an orderly shutdown of the Erlang Node.
|
15
|
+
|
16
|
+
Erlnixify ensures that the Erlang node is up and running and checks
|
17
|
+
every few seconds (a configurable value) to see if everything is
|
18
|
+
continueing to run correctly. If those checks fail, Erlnixify will
|
19
|
+
shut down the Erlang node and then shut itself down so that whatever
|
20
|
+
is managing the system can restart.
|
21
|
+
|
22
|
+
Erlnixify is designed to simply front the Erlang node. It does not
|
23
|
+
provide restarts, log rotation, or anything like that. Those things
|
24
|
+
are expected to be provided by the system (daemontools again).
|
25
|
+
|
26
|
+
Erlnixify can be configured from the command line or via a config
|
27
|
+
file. Command line configuration overrides config file
|
28
|
+
configuration. That is, if a configuration value is provided both on
|
29
|
+
the command line and in the config file, the value on the command line
|
30
|
+
is the one that will be used.
|
31
|
+
|
32
|
+
** Erlnixify is designed to manage releases. **
|
33
|
+
** For self contained releases that do not have Erlang on the system,
|
34
|
+
you must include `erl_interface` **
|
35
|
+
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
Erlnixify requires ruby 1.9. It does not work on 1.8, but may work on
|
40
|
+
2.0+ though it has not been tested.
|
41
|
+
|
42
|
+
Add this line to your application's Gemfile:
|
43
|
+
|
44
|
+
gem 'erlnixify'
|
45
|
+
|
46
|
+
And then execute:
|
47
|
+
|
48
|
+
$ bundle
|
49
|
+
|
50
|
+
Or install it yourself as:
|
51
|
+
|
52
|
+
$ gem install erlnixify
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
### SYNOPSIS
|
57
|
+
|
58
|
+
`erlnixify` [<optional>...] <flags>
|
59
|
+
|
60
|
+
### EXAMPLE
|
61
|
+
|
62
|
+
The following example shows how to run a bare non-otp erlang
|
63
|
+
module. This is *not* the recommended way to do this at all. You
|
64
|
+
should be using Erlang releases, however it does work and it does
|
65
|
+
illustrate the point.
|
66
|
+
|
67
|
+
erlnixify --name example \
|
68
|
+
--cookie fubachu \
|
69
|
+
--command "erl -setcookie %{cookie} -name %{fullname} -noshell -s my_module start"
|
70
|
+
|
71
|
+
The above is enough to get things going with the default
|
72
|
+
values. Running a release might be a bit more complicated. Its more
|
73
|
+
complicated because you are going to want to provide a custom check
|
74
|
+
commands and perhaps custom check intervals.
|
75
|
+
|
76
|
+
erlnixify --name example2 \
|
77
|
+
--cookiefile /etc/example2/mycookiefile \
|
78
|
+
--release /opt/example2 \
|
79
|
+
--command '/opt/example2/bin/example2 -setcookie %{cookie} -name=%{fullname} +Ktrue +B -noinput -shutdown_time 5000 +W w' \
|
80
|
+
--check "example2 check_status" \
|
81
|
+
--checkregex '^ok$' \
|
82
|
+
--checkinterval 100
|
83
|
+
|
84
|
+
The above assumes we have a viable OTP Release in the /opt/example2
|
85
|
+
directory. We have placed our cookie in a file in
|
86
|
+
/etc/example2/mycookiefile and we have a script to start our release
|
87
|
+
that lives in the bin directory of the release. We have provided a
|
88
|
+
module `example2` with a function `check_status` that takes no
|
89
|
+
arguments to check the status of the system. If it returns an `ok`
|
90
|
+
everything is good. We are also going to run that check command every
|
91
|
+
100 seconds.
|
92
|
+
|
93
|
+
|
94
|
+
We could, of course, have put all the above in a config file as well.
|
95
|
+
|
96
|
+
name: example2
|
97
|
+
cookiefile: /etc/example2/mycookiefile
|
98
|
+
release: /opt/example2
|
99
|
+
command: /opt/example2/bin/example2 -setcookie %{cookie} -name=%{fullname} +Ktrue +B -noinput -shutdown_time 5000 +W w
|
100
|
+
check: example2 check_status
|
101
|
+
checkregex: ^ok$
|
102
|
+
checkinterval: 100
|
103
|
+
|
104
|
+
Then our Erlnixify could have been much simpler. Assuming our config
|
105
|
+
file was at `/etc/example2/erlnixify-config.yaml` or Erlnixify command
|
106
|
+
line could have been.
|
107
|
+
|
108
|
+
erlnixify --configfile /etc/example2/erlnixify-config
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
### Options
|
113
|
+
|
114
|
+
* `-b`, `--release`=<release-root>
|
115
|
+
|
116
|
+
The root directory of the Release that Erlnixify is
|
117
|
+
managing. Erlnixify expects to always be managing a release. This
|
118
|
+
is optional if the `erlang` option is provided.
|
119
|
+
|
120
|
+
* `-b`, `--erlang`=<erlang-root>
|
121
|
+
|
122
|
+
The erlang root directory for the system. This only needs to be
|
123
|
+
used if both the `release` option is not specified and the erlang
|
124
|
+
install is in a strange place.
|
125
|
+
|
126
|
+
* `-o`, `--home`=<home-dir>
|
127
|
+
|
128
|
+
The home directory that should be set for the running system. This
|
129
|
+
is set by default to the `HOME` directory of the user running
|
130
|
+
erlnixify. However, in instances where that should be different or
|
131
|
+
the user has no `HOME` directory, this option can be provided.
|
132
|
+
|
133
|
+
* `-n`, `--name`=<short node name>
|
134
|
+
|
135
|
+
The short node name for this system. This is not
|
136
|
+
optional. Erlnixify uses distributed erlang to manage and control
|
137
|
+
the Erlang system.
|
138
|
+
|
139
|
+
* `--fullnode`=<full node name>
|
140
|
+
|
141
|
+
When only `name` is provided, Erlnixify takes the host name of the
|
142
|
+
system as provided by `hostname -f` and concatinates it with the
|
143
|
+
value provided in `name` to come up with a fully qualified host
|
144
|
+
name. The user can use this to override that full name.
|
145
|
+
|
146
|
+
* `-m`, `--command`=<node start command>
|
147
|
+
|
148
|
+
This is the command that should be used to start the node. This command may contain variables that will be filled out by the Erlnixify system. Those variables are any one of the following.
|
149
|
+
|
150
|
+
* `release` - as described adove
|
151
|
+
* `erlang` - as described above
|
152
|
+
* `home` - as described above
|
153
|
+
* `name` - as described above
|
154
|
+
* `fullname` - The full name of the Erlang node, either as provided
|
155
|
+
or as discovered by Erlnixify. This value will always be populated
|
156
|
+
* `cookie` - The cookie provided. This value will always be populated
|
157
|
+
* `startuptimeout` - as described belov
|
158
|
+
* `checkinterval` - as described below
|
159
|
+
* `checktimeout` - as described below
|
160
|
+
|
161
|
+
* `-k`, `check`=< the command used to check the status of the system>
|
162
|
+
|
163
|
+
This is an erlang module/function call in
|
164
|
+
[erl_call](http://www.erlang.org/doc/man/erl_call.html) format. The
|
165
|
+
default value for this command is `erlang statistics
|
166
|
+
[reductions]`. However, that is not tremendously useful and you
|
167
|
+
really should provide your own.
|
168
|
+
|
169
|
+
* `-r`, `--checkregex`=<regular expression>
|
170
|
+
|
171
|
+
This is a regular expression that is used to check the output of the
|
172
|
+
above mentioned check command. If this regular expression does not
|
173
|
+
match the output of the check command then the command is expected
|
174
|
+
to have failed and the node will be shut down. By default this value
|
175
|
+
is `^{\\d+, \\d+}$`. This matches the default `check` command. If
|
176
|
+
you change the `check` command (and you should) you must change this
|
177
|
+
value to match your expected output otherwise the system will always
|
178
|
+
fail on the first check.
|
179
|
+
|
180
|
+
* `-x`, `--cookiefile`=<path to file that contains the cookie>
|
181
|
+
|
182
|
+
If the `cookie` option is set this option is not needed. This should
|
183
|
+
point to a file that contains the cookie that the system should
|
184
|
+
use. That file must contain only the cookie. Be careful that you do
|
185
|
+
not include a trailing newline.
|
186
|
+
|
187
|
+
* `-i`, `--cookie`=<cookie value>
|
188
|
+
|
189
|
+
The actual value that Erlnixify should use as a cookie. This isn't
|
190
|
+
needed if the `cookiefile` option is provided.
|
191
|
+
|
192
|
+
* `-t`, `--startuptimeout`=<seconds that the node has to startup>
|
193
|
+
|
194
|
+
This is the number of seconds that the node has to startup. If the
|
195
|
+
node is not running in that amount of time Erlnixify will shut it
|
196
|
+
down and exit. The default value is 60.
|
197
|
+
|
198
|
+
* `-a`, `--checkinterval`=<seconds between each check>
|
199
|
+
|
200
|
+
The number of seconds between each check. The default value is 30.
|
201
|
+
|
202
|
+
|
203
|
+
* `-w`, `--checktimeout`=<seconds that the check command is allowed to run>
|
204
|
+
|
205
|
+
This is the number of seconds that the check command is allowed to
|
206
|
+
run. If the check command takes longer then this number of seconds
|
207
|
+
then Erlnixify will kill the Erlang node and exit.
|
208
|
+
|
209
|
+
* `-c`, `--config`=<path to config file>
|
210
|
+
|
211
|
+
The path to a [YAML](http://yaml.org) based config file. The keys
|
212
|
+
are the same as described here for the long version of the
|
213
|
+
options. A config file is optional if the command line options are
|
214
|
+
set instead.
|
215
|
+
|
216
|
+
* `-v`, `--version`
|
217
|
+
|
218
|
+
Print out the version of Erlnixify
|
219
|
+
|
220
|
+
* `-h`, `--help`
|
221
|
+
|
222
|
+
Print out the help for erlnixify
|
223
|
+
|
224
|
+
## Contributing
|
225
|
+
|
226
|
+
See [Contributing](https://github.com/erlware/erlnixify/blob/master/CONTRIBUTING.md)<
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "reek/rake/task"
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
task :default => :quality
|
7
|
+
|
8
|
+
Reek::Rake::Task.new do |t|
|
9
|
+
t.fail_on_error = true
|
10
|
+
t.reek_opts = "-c ./reek.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
14
|
+
t.cucumber_opts = "features --format pretty"
|
15
|
+
end
|
16
|
+
|
17
|
+
task :console do
|
18
|
+
exec 'irb -I lib -r startingscript.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
task :quality => [:reek, :features] do
|
22
|
+
end
|
data/erlnixify.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'erlnixify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "erlnixify"
|
8
|
+
spec.version = Erlnixify::VERSION
|
9
|
+
spec.authors = ["Eric Merritt"]
|
10
|
+
spec.email = ["ericbmerritt@gmail.com"]
|
11
|
+
spec.description = %q{Erlnixify's purpose is to rectify a problem in Erlang. At the moment
|
12
|
+
the Erlang VM has the problem that it can not react to unix
|
13
|
+
signals. This renders it impossible to integrate Erlang into a basic
|
14
|
+
unix environment like init.d or daemontools. This ruby project is
|
15
|
+
designed to fill that void. It provides a small unix executable whose
|
16
|
+
responsibility it is to capture normal unix signals and translate them
|
17
|
+
into something that the erlang vm can understand.
|
18
|
+
}
|
19
|
+
spec.summary = %q{An executable to help integrate Erlang Releases with unix sytems}
|
20
|
+
spec.homepage = ""
|
21
|
+
spec.license = "Apache 2.0"
|
22
|
+
|
23
|
+
spec.files = `git ls-files`.split($/)
|
24
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
29
|
+
spec.add_development_dependency "rake"
|
30
|
+
spec.add_development_dependency "reek"
|
31
|
+
spec.add_development_dependency "cane"
|
32
|
+
spec.add_development_dependency "cucumber", "~> 1.3.1"
|
33
|
+
|
34
|
+
spec.add_dependency "slop", "~> 3.4.4"
|
35
|
+
end
|