-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebar_release.html
273 lines (210 loc) · 8.04 KB
/
rebar_release.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="keywords" content="Yaws"/>
<title>Yaws</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="stil.css"/>
<link rel="shortcut icon" href="/icons/yaws_y.gif" type="image/x-icon"/>
</head>
<body>
<div class="logo">
<img src="icons/yaws_head.gif" width="600" alt="YAWS"/>
</div>
<div id="sidebar">
<h4> Yaws </h4>
<div class=""> <a href="index.html" id="index" >Top Page</a> </div>
<div class=""> <a href="configuration.html" id="configuration">Build Config and Run</a></div>
<div class=""> <a href="dynamic.html" id="dynamic" >Dynamic Content</a> </div>
<div class=""> <a href="https://github.com/erlyaws/yaws/releases/" id="download">Download </a> </div>
<div class=""> <a href="contact.html" id="contact">Contact </a> </div>
<div class=""> <a href="doc.html" id="doc">Documentation</a> </div>
<div class=""> <a href="articles.html" id="resources">Articles</a> </div>
<h4> Examples </h4>
<div class=""> <a href="/json_intro.html">AJAX/JSON RPC</a></div>
<div class=""> <a href="/appmods.html">Appmods</a> </div>
<div class=""> <a href="/arg.html">Arg</a> </div>
<div class=""> <a href="/privbind.html">Binding to Privileged Ports</a></div>
<div class=""> <a href="/bindings.html">Bindings</a> </div>
<div class=""> <a href="/cgi.html">CGI</a></div>
<div class=""> <a href="/session.html">Cookie Sessions</a> </div>
<div class=""> <a href="/cookies.html">Cookies</a> </div>
<div class=""> <a href="/dynamic.html">Dynamic Content</a> </div>
<div class=""> <a href="/embed.html">Embedding Yaws</a></div>
<div class=""> <a href="/upload0.html">File Upload</a> </div>
<div class=""> <a href="/form.html">Forms</a> </div>
<div class=""> <a href="/haxe_intro.html">haXe Remoting</a></div>
<div class=""> <a href="/pcookie.html">Persistent Cookies</a> </div>
<div class=""> <a href="/query.html">Query Part of URL</a></div>
<div class=""> <a href="/rebar_release.html">Rebar Releases</a></div>
<div class=""> <a href="/redirect.html">Redirect</a> </div>
<div class=""> <a href="/server_sent_events.html">Server-Sent Events</a> </div>
<div class=""> <a href="/ssi.html">Server Side Includes</a> </div>
<div class=""> <a href="/simple.html">Simple</a> </div>
<div class=""> <a href="/soap_intro.html">SOAP with Yaws</a></div>
<div class=""> <a href="/stream.html">Streaming Data</a> </div>
<div class=""> <a href="/websockets.html">Web Sockets</a> </div>
<a href="/shoppingcart/index.html">Tiny Shopping Cart</a>
<div class=""> <a href="/yapp_intro.html">Yaws Applications (yapps)</a></div>
<div class=""> <a href="/logger_mod.html">Write Your Own Logger</a></div>
<h4> Misc </h4>
<div class=""> <a href="/internals.html">Internals</a> </div>
</div>
<div id="entry">
<h1>Creating a Release with Rebar</h1>
<p>
One way to create an Erlang release for a project that depends on Yaws,
or a set of applications that includes Yaws, is to use the <a
href="https://github.com/rebar/rebar">rebar</a> build tool. This page
details the steps required to set up the proper directory structure for
such a project, create and generate the necessary release configuration
files, and how to package a release for later installation and
deployment.
</p>
<h2>Rebar Templates</h2>
<p>
The easiest way to build a release that uses Yaws is to use the rebar
template files found under the rebar-templates directory found at the
top-level of the Yaws repository. To do this, first copy all the files
in the rebar-templates directory into your $HOME/.rebar/templates
directory, creating it if necessary:
</p>
<p>
<div class="box">
<pre>
$ mkdir -p ~/.rebar/templates
$ cp rebar-templates/* ~/.rebar/templates
</pre>
</div>
</p>
<p>
Next, run rebar in your <code>foo</code> project directory to create a
release project skeleton, specifying the yawsnode template so rebar
knows what to create. Note also that we specify <code>foo</code> as the
nodeid and <code>myapp</code> as the appid:
</p>
<p>
<div class="box">
<pre>
$ cd /path/to/foo
$ rebar create template=yawsnode nodeid=foo appid=myapp
</pre>
</div>
</p>
<p>
This creates two subdirectories and a rebar.config file, described
below:
</p>
<p>
<dl>
<dt><code>apps</code></dt>
<dd>
holds directories for the applications that comprise the
<code>foo</code> project
</dd>
<dt><code>rebar.config</code></dt>
<dd>
build configuration for the <code>foo</code> project
</dd>
<dt><code>rel</code></dt>
<dd>
provides support files for creating project releases
</dd>
</dl>
</p>
<h3>The apps Directory</h3>
<p>
Let's assume we have a single application named <code>myapp</code> that
depends on Yaws, and <code>myapp</code> and Yaws together comprise the
<code>foo</code> project. The <code>apps</code> directory therefore
contains a <code>myapp</code> subdirectory, which is a normal Erlang
project directory that should contain its own <code>rebar.config</code>
file, a <code>src</code> directory containing Erlang source code,
etc. Since <code>myapp</code> depends on Yaws, its
<code>rebar.config</code> file should specify Yaws as a
dependency. Note that the yawsnode rebar template does not create any
of this for you; you're expected to create your own application files
yourself.
</p>
<h2>Building the Project</h2>
<p>
To build the <code>foo</code> project, use rebar:
</p>
<p>
<div class="box">
<pre>
$ rebar get-deps compile
</pre>
</div>
</p>
<p>
This first fetches all dependencies for all the applications under the
<code>apps</code> directory, and the compiles them along with all the
apps.
</p>
<h2>Creating a Release</h2>
<p>
Once everything is compiled, you can change to the <code>rel</code>
directory and generate a release. Prior to that, though, you might want
to edit the rel/files/yaws.conf file to ensure Yaws will be configured
properly for your project when you run the generated release. That file
is copied into the generated release. Once you've done that, run "rebar
generate" in the rel directory:
</p>
<p>
<div class="box">
<pre>
$ cd rel
$ rebar generate
</pre>
</div>
</p>
<p>
Because we specified the nodeid as <code>foo</code> when we created the
project, the generation step creates a <code>foo</code> directory under
rel that holds the generated release. It contains an Erlang runtime
along with all the standard and application-specific modules and
support files needed to run your project, all in a relocatable
directory structure. To package it for deployment, just tar it up:
</p>
<p>
<div class="box">
<pre>
$ cd foo
$ tar zcf ../foo.tar.gz *
</pre>
</div>
</p>
<p>
This packs up the whole release into the file rel/foo.tar.gz.
</p>
<h2>Deploying the Project</h2>
<p>
To deploy your project release, copy the tar file onto the target host,
unpack it into an installation directory of your choice, and then run
the <code>install.sh</code> script to ensure any absolute paths in the
release reflect the chosen installation directory. You can then run the
node using the <code>bin/foo</code> script:
</p>
<p>
<div class="box">
<pre>
$ < login to target host, copy foo.tar.gz over >
$ cd /install/path
$ tar zxf foo.tar.gz
$ ./install.sh
$ ./bin/foo console
</pre>
</div>
</p>
<p>
The final command above starts the node with an interactive shell. Once
it's running, Yaws and all the other applications that comprise the
project will be executing. You can alternatively start the node as a
daemon by running "./bin/foo start" and later stop it with "./bin/foo
stop". Run "./bin/foo" with no arguments to see all its other
command-line arguments.
</p>
</div>