/usr/share/doc/monotone/html/Network-Service-Revisited.html is in monotone-doc 1.1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.0, http://www.gnu.org/software/texinfo/ -->
<head>
<title>monotone documentation: Network Service Revisited</title>
<meta name="description" content="monotone documentation: Network Service Revisited">
<meta name="keywords" content="monotone documentation: Network Service Revisited">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="General-Index.html#General-Index" rel="index" title="General Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Tutorial.html#Tutorial" rel="up" title="Tutorial">
<link href="Advanced-Uses.html#Advanced-Uses" rel="next" title="Advanced Uses">
<link href="Branching-and-Merging.html#Branching-and-Merging" rel="prev" title="Branching and Merging">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space: nowrap}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: serif; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="texinfo.css">
</head>
<body lang="en">
<a name="Network-Service-Revisited"></a>
<div class="header">
<p>
Previous: <a href="Branching-and-Merging.html#Branching-and-Merging" accesskey="p" rel="prev">Branching and Merging</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="General-Index.html#General-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Network-Service-Revisited-1"></a>
<h3 class="section">2.13 Network Service Revisited</h3>
<p>Up until now, Jim has been using his laptop and database as a sort of
“central server” for the company; Abe and Beth have been syncing with
Jim, and learning of each other’s work via Jim’s database. This has
worked fine while the product has been in early development; Jim has
good network connectivity in Japan, and has been staying home
concentrating on programming. He has been able to leave his laptop
connected and running all the time, while his employees in different
time-zones work and sync their databases. This is now starting to
change, and two problems are starting to cause occasional difficulties.
</p>
<ul>
<li> First, Jim is finding that he has to spend more of his time
travelling, demonstrating the new juicebot features to customers; thus
his laptop is spending more time disconnected from the network, or
connected at dynamic addresses where it’s not convenient for Abe and
Beth to find him and sync.
<p>This doesn’t prevent them doing any work, but it does have some
uncomfortable consequences: they’re more likely to have to manually
merge conflicting changes when they finally sync up and discover they’ve
both come up with slightly different fixes for the same bug in the
meantime, and they’re more exposed to loss of work if one of them
suffers a disk failure before they’ve had a chance to sync that work
with another database.
</p>
</li><li> Second, because Jim has been using the one database file both for his
own local work, and for serving to the others in the team, he
occasionally finds that the monotone serve process (busy syncing with
Abe or Beth) has a lock on the database, while he’s trying to do local
work like updates or commits.
<p>The level of project activity is picking up, and there are more and more
changes to be synced in the narrower window of time while Jim is
connected. He finds he sometimes needs to take down the server process
to do this local work, further exacerbating the first problem.
</p></li></ul>
<p>The juicebot team are resourceful, and by now quite used to working
independently. While Jim has been away travelling, Abe and Beth have
come up with their own solution to the first problem: they’ll run
servers from their databases, setting them up just like Jim did
previously. That way, if Jim’s database is offline, either Beth or Abe
can run the <code>serve</code> command and provide access for the other to
<code>sync</code> with. Beth also has the idea to create a second database
for the <code>serve</code> process, and to <code>sync</code> her development
database with that server locally, avoiding locking contention between
multiple monotone processes on the one database file.
</p>
<p>When Jim reappears, the next person to <code>sync</code> with him will
often pass him information about both employees’ work that they’ve
sync’ed with each other in the meantime, just as he used to do. In fact,
Jim now finds it more convenient to initiate the sync with one of the
other servers when he has a spare moment and dynamic connectivity from a
hotel room or airport. Changes will flow between servers automatically
as clients access them and trade with one another.
</p>
<p>This gets them by for a while, but there are still occasional
inconveniences. Abe and Beth live in very different time-zones, and
don’t always have reliable network connectivity, so sometimes Jim finds
that neither of them is online to sync with when he has the chance. Jim
now also has several customers interested in beta-testing the new code,
and following changes as the bugs and issues they report are addressed.
</p>
<p>Jim decides it’s time for a permanent server they can all sync with;
this way, everyone always knows where to go to get the latest changes,
and people can push their changes out without first calling their
friends and making sure that they have their servers running.
</p>
<p>Jim has rented some web server space on a service provider’s shared
system for the JuiceBot Inc. public website, <code>www.juicebot.co.jp</code>;
he thinks this server will be a good place to host the central monotone
server too. He sets up a new monotone database on the server,
generates a new key specially for the server (so he doesn’t have to
expose his own development private key on the shared system), and loads
in the team-members’ keys:
</p>
<div class="smallexample">
<pre class="smallexample">$ mtn --db=server.mtn db init
$ mtn genkey monotone-server@www.juicebot.co.jp
enter passphrase for key ID [monotone-server@www.juicebot.co.jp] (...): <i><Jim enters a new passphrase></i>
confirm passphrase for key ID [monotone-server@www.juicebot.co.jp] (...): <i><Jim confirms the passphrase></i>
mtn: generating key-pair 'monotone-server@www.juicebot.co.jp'
mtn: storing key-pair 'monotone-server@www.juicebot.co.jp' in /home/jim/.monotone/keys
mtn: key 'abe@juicebot.co.jp' has hash '78be08f7a2a316a9f7c6b0db544ed20673ea2190'
$ cat abe.pubkey beth.pubkey jim.pubkey | mtn --db=server.mtn read
mtn: read 3 packets
</pre></div>
<p>For the team members, he sets up the permissions files on the server
much like before — except that of course he needs to also grant his
<code>jim@juicebot.co.jp</code> key permission to access the new server.
For the beta-testers, Jim wants to allow them read-only access just to
the main JuiceBot 7 development line, but not to any of the
sub-branches where other experimental development is going on. He adds
some lines at the top of the <samp>~/.monotone/read-permissions</samp> on
the server, above the broader permissions given to team-members. See
<a href="Netsync-Permission-Hooks.html#get_005fnetsync_005fread_005fpermitted">get_netsync_read_permitted</a> for more details; the resulting file
looks like this:
</p>
<div class="smallexample">
<pre class="smallexample">comment "Provide beta-testers with specific read-only access"
pattern "jp.co.juicebot.jb7"
allow "beta1@juicebot.co.jp"
allow "beta2@juicebot.co.jp"
continue "true"
comment "Fall-through, and allow staff access to all branches"
pattern "*"
allow "abe@juicebot.co.jp"
allow "beth@juicebot.co.jp"
allow "jim@juicebot.co.jp"
</pre></div>
<p>Jim could log in and start the monotone process manually from his shell
account on the server, perhaps under a program like screen to let it
stay running while he’s away. This would be one way of giving it the
server-key’s passphrase each startup, but he wants to make sure that the
server is up all the time; if the host reboots while he’s travelling and
the monotone server is down until he next logs in, things aren’t much
better than before. For the server to start automatically each time,
he’ll need to use the <code>get_passphrase</code> hook in the server’s
<samp>monotonerc</samp> file again.
</p>
<p>Because he’s running on a shared server, Jim needs to be a little more
restrictive about which interfaces and addresses his new server process
will listen on. He should only accept connections at the address used
for his website, because some of the provider’s other customers might
also want to publish their own monotone projects on this host. Jim uses
the <samp>--bind=<var>address</var>:<var>port</var></samp> argument like so:
</p>
<div class="smallexample">
<pre class="smallexample">$ mtn --db=server.mtn --bind=www.juicebot.co.jp serve
</pre></div>
<p>This will start monotone listening on the default port (4691), but only
on the IP address associated with <code>www.juicebot.co.jp</code>. Jim can do
this because his hosting provider has given him a dedicated IP address
for his website. If the hosting provider offered only a single shared
IP address belonging to the server, each customer could bind a different
port number on that address.
</p>
<p>While he’s first testing the setup, Jim uses
<samp>--bind=localhost:1234</samp>. This causes the monotone process to listen
only to port 1234 on the loopback interface 127.0.0.1, which is not
accessible from the network, so Jim doesn’t expose an open port to the
rest of the world until he’s satisfied with the permissions
configuration. You can cause monotone to listen on all interfaces on
port 1234 by leaving out the address part like <samp>--bind=:1234</samp>.
</p>
<p>When he’s satisfied the server is set up correctly, Jim does an initial
<code>sync</code> with the new database, filling it with all the revision
history currently on his laptop. While Jim has been busy setting up the
server, Abe and Beth have kept working; the server will catch up with
their latest changes when they next sync, too.
</p>
<p>All of the team members now want to sync with the new monotone server
by default. Previously, they had been syncing with Jim’s laptop by
default, even if they occasionally specified another team-member’s
server on the command line when Jim was away, because monotone had
remembered the first server and branch patterns used in database vars
(see <a href="Vars.html#Vars">Vars</a>). These vars can be seen as follows:
</p>
<div class="smallexample">
<pre class="smallexample">$ mtn list vars
database: default-exclude-pattern
database: default-include-pattern jp.co.juicebot.jb7*
database: default-server jim-laptop.juicebot.co.jp
known-servers: jim-laptop.juicebot.co.jp 9e9e9ef1d515ad58bfaa5cf282b4a872d8fda00c
known-servers: abe-laptop.juicebot.co.jp a2bb16a183247af4133621f7f5aefb21a9d13855
known-servers: www.juicebot.co.jp 120a99ch93b4f174432c13d3e3e9f2234aa92612
</pre></div>
<p>The team members can reset their local database vars accordingly:
</p>
<div class="smallexample">
<pre class="smallexample">$ mtn set database default-server www.juicebot.co.jp
</pre></div>
<p>With their new server, the juicebot team have gained the convenience of
a readily available common point of reference for syncs. However, they
also know that this is there only as a convenience, and doesn’t prevent
them working as they did before:
</p><ul>
<li> The team members can still sync with each other if needed.
<p>Hopefully, their new server won’t ever be down, but sometimes they might
be working together while away from ready network access — fixing up
the last few issues and finalising presentation materials while
travelling to a sales conference, for example. The server will learn of
these changes on the next sync.
</p></li><li> The team members continue to discover multiple heads and changes that
need merging, as before. Each team member can merge the heads, and will
produce the same revision id if they merge to the same result.
<p>They now develop a new habit out of courtesy, though — they try not to
leave multiple heads and unmerged changes on the server, at least not
for long. This saves them from repeating work, and also helps prevent
confusion for the beta-testers. When each team member is ready to
<code>sync</code>, they develop the habit of doing a <code>pull</code> from
the server first. If new revisions were received from the server, they
first <code>merge</code> their new revisions with the head(s) from the
server, and finally <code>sync</code> to publish their merged changes as
one. If the last <code>sync</code> happens to pull in new revisions again
from the server, it means someone else has deposited new work at the
same time, and another <code>merge</code> and <code>sync</code> would probably
be polite.
</p></li><li> Jim knows he doesn’t have to keep a special backup of the new server’s
contents; if the server should fail, all the contents of its database
can be found amongst the other team members (especially because no
commits are done on the server itself).
<p>He does, however, take a copy of the server’s private key, so he can
restore that if necessary.
</p></li><li> In fact, Jim realises that he can now commit a copy of the web site’s
current contents into monotone on a new branch,
<code>jp.co.juicebot.www</code>, and keep a backup of that content too.
<p>Now he can use monotone to work on the website offline, and let other
team members add and edit the content; he can also preview changes
locally before updating the production content. He keeps a workspace
checkout of this content in the webroot on the server, and runs a
monotone <code>update</code> in there when he wants to bring the public web
site up to date. Later, he’ll think about using monotone’s <a href="Quality-Assurance.html#Quality-Assurance">Quality Assurance</a> mechanisms and Event Notification <a href="Hooks.html#Hooks">Hooks</a>, so that the
web server can update itself automatically when appropriate new
revisions are received.
</p></li><li> Jim also knows that even if someone should break into the shared hosting
server and tamper with the database, they won’t be able to inject
malicious code into the project, because all revisions are signed by the
team members, and he has set his <a href="Trust-Evaluation-Hooks.html#Trust-Evaluation-Hooks">Trust Evaluation Hooks</a> so he
doesn’t trust the server key for signing revisions.
<p>In monotone, the important trust consideration is on the <em>signed
content</em>, rather than on the <em>replication path</em> by which that
content arrived in your database.
</p></li></ul>
<hr>
<div class="header">
<p>
Previous: <a href="Branching-and-Merging.html#Branching-and-Merging" accesskey="p" rel="prev">Branching and Merging</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="General-Index.html#General-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|