-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting-up-rethinkdb-with-lunchy.html
51 lines (49 loc) · 12.9 KB
/
setting-up-rethinkdb-with-lunchy.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
<!DOCTYPE html>
<html> <head lang=en><meta charset=UTF-8><title>Setting up Rethinkdb with Lunchy | EF</title><link href=//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css rel=stylesheet><link href=http://fonts.googleapis.com/css?family=Inconsolata rel=stylesheet type=text/css><link rel=stylesheet href=http://nafiulis.me/theme/css/main.css><link rel=stylesheet href=http://nafiulis.me/theme/css/pygment.css><script src=http://nafiulis.me/theme/js/jquery.min.js></script><script src=http://nafiulis.me/theme/js/main.js></script></head> <body> <!--Heading at the top saying "Engineering Fantasy"--> <div id=header_top> <div class=title> <a href=http://nafiulis.me><span id=engineering>Engineering</span><span id=fantasy>Fantasy</span></a> </div> </div> <button type=button class="js-menu-trigger sliding-menu-button button-nav"> <img src=https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/menu-white.png alt="Menu Icon"> </button> <!--Navigation Bar--> <nav class="js-menu sliding-menu-content"> <span class=section-header>Pages</span> <ul> <li><a href=http://nafiulis.me>Home</a></li> <li><a href=http://nafiulis.me/tags.html>Tags</a></li> <li><a href=http://nafiulis.me/pages/about-me.html>About Me</a></li> </ul> <span class=section-header>Categories</span> <ul> <li><a href=http://nafiulis.me/category/anime.html>Anime</a></li> <li><a href=http://nafiulis.me/category/education.html>Education</a></li> <li><a href=http://nafiulis.me/category/productivity.html>Productivity</a></li> <li><a href=http://nafiulis.me/category/programming.html>programming</a></li> <li><a href=http://nafiulis.me/category/rants.html>rants</a></li> </ul> </nav> <div class="js-menu-screen menu-screen"></div> <!--Main Container--> <div class=container> <!--Top most menu--> <div id=menu> <div class=left> <a href=http://nafiulis.me/feeds/all.atom.xml><i class="fa fa-rss
icon"></i></a> <a href=https://twitter.com/gamesbrainiac><i class="fa fa-twitter icon"></i></a> </div> <div class=center> <h1 class=message>Nafiul Islam on casting spells with code</h1> </div> <div class=right> <a href=https://github.com/gamesbrainiac><i class="fa fa-github icon"></i></a> <a href=http://stackoverflow.com/users/1624921/games-brainiac><i class="fa fa-stack-overflow icon" style="padding-right: 30px"></i></a> </div> </div> <!--Main blog list container--> <div id=blogroll> <div class=article-container> <h1>Setting up Rethinkdb with Lunchy</h1> <p class=time>Sunday, 27 September 2015</p> <div class=article-content> <div class="contents topic" id=table-of-contents> <p class="topic-title first">Table of Contents</p> <ul class=simple> <li><a class="reference internal" href=#installation id=id6>Installation</a></li> <li><a class="reference internal" href=#setup id=id7>Setup</a></li> <li><a class="reference internal" href=#launching id=id8>Launching</a></li> </ul> </div> <p>Rethinkdb is a powerful new NoSQL database that comes with its one web-based admin console. However, its a bit awkward to set up. The installation is not hard when you have a one line homebrew installation or if you prefer to install it as an application, then you can simply use the use their disk image provided as a url <a class="reference external" href=https://www.rethinkdb.com/docs/install/osx/ >download</a> on their OSX installation page. However, the Rethinkdb command line tool is a bit awkward in the sense that it just creates a directory to store your data in the same directory that you launch it. This is a simple tutorial on how to set rethinkdb as a service so that it stores your data in the same place with a proper set of default configurations.</p> <div class=section id=installation> <h2><a class=toc-backref href=#id6>Installation</a></h2> <p>I would highly recommend using homebrew to install rethinkdb. Its a painless process and gives you full control as to how you use the <code>rethinkdb</code> CLI.</p> <div class=highlight><pre><span></span>brew install rethinkdb
</pre></div> <p>Now, we are going to install <code>lunchy</code>, which is a wrapper over <code>launchctl</code>, that basically starts and stops our services in a simple manner.<a class=footnote-reference href=#lunchy id=id1>[1]</a> <a class=footnote-reference href=#agentsanddemons id=id2>[2]</a></p> <div class=highlight><pre><span></span>gem install lunchy
</pre></div> </div> <div class=section id=setup> <h2><a class=toc-backref href=#id7>Setup</a></h2> <p>The first thing that we need to do is install the <code>rethinkdb</code> plist file in our LaunchAgents directory. We can do this by firstly creating a file called <code>com.rethinkdb.server.plist</code> and then running <code>lunchy install</code> on that file. My own configuration is shown below.</p> <div class=highlight><pre><span></span><span class=cp><?xml version="1.0" encoding="UTF-8"?></span>
<span class=cp><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"></span>
<span class=nt><plist</span> <span class=na>version=</span><span class=s>"1.0"</span><span class=nt>></span>
<span class=nt><dict></span>
<span class=nt><key></span>Label<span class=nt></key></span>
<span class=nt><string></span>com.rethinkdb.server<span class=nt></string></span>
<span class=nt><key></span>ProgramArguments<span class=nt></key></span>
<span class=nt><array></span>
<span class=nt><string></span>/usr/local/bin/rethinkdb<span class=nt></string></span>
<span class=nt><string></span>-d<span class=nt></string></span>
<span class=nt><string></span>/Users/quazinafiulislam/Library/RethinkDB/data<span class=nt></string></span>
<span class=nt></array></span>
<span class=nt><key></span>StandardOutPath<span class=nt></key></span>
<span class=nt><string></span>/Users/quazinafiulislam/Library/Rethinkdb/out.log<span class=nt></string></span>
<span class=nt><key></span>StandardErrorPath<span class=nt></key></span>
<span class=nt><string></span>/Users/quazinafiulislam/Library/Rethinkdb/error.log<span class=nt></string></span>
<span class=nt><key></span>RunAtLoad<span class=nt></key></span>
<span class=nt><false/></span>
<span class=nt><key></span>KeepAlive<span class=nt></key></span>
<span class=nt><true/></span>
<span class=nt><key></span>LowPriorityIO<span class=nt></key></span>
<span class=nt><false/></span>
<span class=nt></dict></span>
<span class=nt></plist></span>
</pre></div> <div class=section id=steps> <h3>Steps</h3> <ul class=simple> <li>Create a file using the <code>touch</code> command, i.e. <code>touch com.rethinkdb.server.plist</code>, and just paste in the contents.</li> <li>Replace <code>quazinafiulislam</code> with your username in the file.<a class=footnote-reference href=#completepaths id=id3>[3]</a></li> <li>Create a new directory, <code>~/Library/Rethinkdb</code>. This place will house all your rethinkdb stuff i.e. data, logs etc.</li> <li>Create a new data directory using <code>rethinkdb create -d ~/Library/Rethinkdb/data</code>.</li> <li>The install the file into your LaunchAgents directory using <code>lunchy install com.rethinkdb.server.plist</code>.</li> <li>Once this is done, create two log files using the <code>touch</code> command to create the output log and the error log inside <code>~/Library/LaunchAgents</code> named <code>out.log</code> and <code>error.log</code> respectively.</li> </ul> <p>This is the express installation, you can of course customize the installation to your needs. For example you can add your own <code>.conf</code> file for rethinkdb.<a class=footnote-reference href=#configure id=id4>[4]</a> You can then add it as a parameter to your program arguments by adding the following to your <code>ProgramArguments</code> inside of <code>array</code>.</p> <div class=highlight><pre><span></span><span class=nt><string></span>--config-file<span class=nt><string></span>
<span class=nt><string></span>/path/to/your/config/file<span class=nt><string></span>
</pre></div> <p>Feel free to change the <code>plist</code> file to your liking. One other thing that you might want to change is the <code>RunAtLoad</code> key. I've set this to <code>false</code>, but you might want <code>rethinkdb</code> to start up when you log into your system.</p> </div> </div> <div class=section id=launching> <h2><a class=toc-backref href=#id8>Launching</a></h2> <p>Launching this is quite easy, all you need to do is tell <code>lunchy</code> that you want to start the <code>rethinkdb</code> service.</p> <div class=highlight><pre><span></span>lunchy start rethinkdb
</pre></div> <p>We can see that the standard output is printed to the <code>out.log</code> file inside of <code>~/Library/Rethinkdb</code>.<a class=footnote-reference href=#port id=id5>[5]</a></p> <img alt="Rethinkdb log" class=align-center src=/images/rethink_01.png> <p>Stopping <code>rethinkdb</code> is also a breeze.</p> <div class=highlight><pre><span></span>lunchy stop rethinkdb
</pre></div> <hr class=docutils> <table class="docutils footnote" frame=void id=lunchy rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id1>[1]</a></td><td>The <a class="reference external" href=https://en.wikipedia.org/wiki/Launchd>Wikipedia Page</a> will give you a good idea of what both <code>launchd</code> and <code>launchctrl</code> are.</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=agentsanddemons rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id2>[2]</a></td><td>If you want to know the difference between a launch agent and a demon, take a look at <a class="reference external" href=http://www.grivet-tools.com/blog/2014/launchdaemons-vs-launchagents/ >this article</a>.</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=completepaths rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id3>[3]</a></td><td>Make sure that when you enter the path of a file or folder in a <code>.plist</code> file, you give the complete path without aliases.</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=configure rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id4>[4]</a></td><td>Learn to configure rethinkdb from their <a class="reference external" href=https://www.rethinkdb.com/docs/config-file/ >configuration documentation page</a>. I would strongly encourage you to create your own <code>.conf</code> file.</td></tr> </tbody> </table> <table class="docutils footnote" frame=void id=port rules=none> <colgroup><col class=label><col></colgroup> <tbody valign=top> <tr><td class=label><a class=fn-backref href=#id5>[5]</a></td><td>You can specify your port as another <code>ProgramArgument</code>.</td></tr> </tbody> </table> </div> </div> </div> <div class=post-meta><span class=meta-type>Category: </span> <span><a href=http://nafiulis.me/category/programming.html>Programming</a></span> <span class=meta-type> Tags: </span> <span> <a href=http://nafiulis.me/tag/rethinkdb.html>Rethinkdb</a>, <a href=http://nafiulis.me/tag/databases.html>databases</a>, <a href=http://nafiulis.me/tag/nosql.html>nosql</a>, <a href=http://nafiulis.me/tag/lunchy.html>lunchy</a> </span> </div> <div id=disqus_thread style="margin-top: 10px; margin-left: 20px; margin-right: 20px;"></div> <script type=text/javascript>
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'nafiulisme'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script> <noscript>Please enable JavaScript to view the <a href=http://disqus.com/?ref_noscript>comments powered by Disqus.</a></noscript> </div> <!--Footer--> <div id=footer> <footer> Code examples licenced under MIT License <br> Copyright <i class="fa fa-copyright"></i> 2018 Quazi Nafiul Islam </footer> </div> </div> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55554110-1', 'auto');
ga('send', 'pageview');
</script> </body> </html>