<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>UnattendedUpgrades &amp;mdash; Simple Engineering</title>
    <link>https://getsimple.works/tag:UnattendedUpgrades</link>
    <description></description>
    <pubDate>Tue, 21 Apr 2026 11:35:28 +0000</pubDate>
    <item>
      <title>How to install upstart</title>
      <link>https://getsimple.works/how-to-install-upstart?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install upstart an event based daemon for starting/stopping tasks on development and production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link&#xA;&#xA;There are a plethora of task execution solutions, for instance systemd and init, rather complex to work with. That makes upstart a good alternative to such tools. &#xA;&#xA;In this article you will learn about:&#xA;&#xA;-- &#xA;&#xA;Tools available for task execution &#xA;How to install upstart task execution&#xA;How to write basic upstart task  &#xA;&#xA;Installing upstart on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update # Fetch list of available updates&#xA;$ apt-get upgrade # Upgrades current packages&#xA;$ apt-get dist-upgrade # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a upstart on Linux using apt&#xA;&#xA;Installing upstart on macOS &#xA; &#xA;upstart is a utility designed mainly for Linux systems. However, macOS has its equivalent, launchctl designed to stop/stop processes prior/after the system restarts.   &#xA;&#xA;Installing upstart on a Windows machine&#xA;&#xA;Whereas macOS  systems and Linux are quite relax when it comes to working with system processes, Windows is a beast on its own way. upstart was built for nix systems but  there is no equivalent on Windows systems: Service Control Manager. It basically has the same ability to check and restart processes that are failing. &#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a mongodb instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is recommended that the only pair minor versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated. &#xA;&#xA;In case of a critical infrastructure piece of processes state management calibre, we expect breaking changes when a new version introduces a configuration setting is added, or dropped between two successive versions. Upstart provides backward compatibility, so chances for breaking changes between two minor versions is really minimal.  &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA;&#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install upstart on various platforms. Even though configuration was beyond the scope of this article*, we managed to get everyday quick refreshers out.&#xA;&#xA;References&#xA;&#xA; An A-Z Index of the Apple macOS command line (macOS bash) and the Apple macOS How-to guides and examples&#xA; Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nginx #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>upstart</code> an event based daemon for starting/stopping tasks on development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<p>There are a plethora of task execution solutions, for instance <code>systemd</code> and <code>init</code>, rather complex to work with. That makes upstart a good alternative to such tools.</p>

<p><strong>In this article you will learn about:</strong></p>

<p><strong>—</strong></p>
<ul><li>Tools available for task execution</li>
<li>How to install <code>upstart</code> task execution</li>
<li>How to write basic <code>upstart</code> task<br/></li></ul>

<h2 id="installing-upstart-on-linux" id="installing-upstart-on-linux">Installing <code>upstart</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update # Fetch list of available updates
$ apt-get upgrade # Upgrades current packages
$ apt-get dist-upgrade # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-upstart-on-linux-using-apt" id="installing-a-upstart-on-linux-using-apt">Installing a <code>upstart</code> on Linux using <code>apt</code></h3>

<h2 id="installing-upstart-on-macos" id="installing-upstart-on-macos">Installing <code>upstart</code> on macOS</h2>

<p><code>upstart</code> is a utility designed mainly for Linux systems. However, macOS has its equivalent, <code>launchctl</code> designed to stop/stop processes prior/after the system restarts.</p>

<h2 id="installing-upstart-on-a-windows-machine" id="installing-upstart-on-a-windows-machine">Installing <code>upstart</code> on a Windows machine</h2>

<p>Whereas macOS  systems and Linux are quite relax when it comes to working with system processes, Windows is a beast on its own way. <code>upstart</code> was built for <code>*nix</code> systems but  there is no equivalent on Windows systems: Service Control Manager. It basically has the same ability to check and restart processes that are failing.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>mongodb</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is recommended that the only pair <strong><em>minor</em></strong> versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated.</p>

<p>In case of a critical infrastructure piece of processes state management calibre, we expect breaking changes when a new version introduces a configuration setting is added, or dropped between two successive versions. Upstart provides backward compatibility, so chances for breaking changes between two minor versions is really minimal.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>upstart</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-upstart-to-start-nodejs-application">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="references" id="references">References</h2>
<ul><li><em><a href="https://ss64.com/osx/">An A-Z Index of the Apple macOS command line (macOS bash)</a></em> and the <em><a href="https://ss64.com/osx/syntax.html">Apple macOS How-to guides and examples</a></em></li>
<li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-upstart</guid>
      <pubDate>Fri, 31 Jan 2020 22:51:29 +0000</pubDate>
    </item>
    <item>
      <title>How to install monit</title>
      <link>https://getsimple.works/how-to-install-monit?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install monit monitoring system on production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link&#xA;&#xA;There are a plethora of monitoring and logging solutions around the internet. This article will not focus on any of those, rather provide alternatives using tools already available in Linux/UNIX environments, that may achieve near same capabilities as any of those solutions. &#xA;&#xA;In this article you will learn about: &#xA;&#xA;--&#xA;&#xA;Difference between logging and monitoring&#xA;Tools available for logging &#xA;Tools available for monitoring &#xA;How to install monitoring and logging tools &#xA;How to connect end-to-end reporting for faster response times. &#xA;&#xA;Installing monit on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update # Fetch list of available updates&#xA;$ apt-get upgrade # Upgrades current packages&#xA;$ apt-get dist-upgrade # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a monit on Linux using apt&#xA;Installing monit on macOS &#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install/uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a monit on a macOS  using homebrew&#xA;&#xA;It is hard to deny the supremacy of monit on NIX systems, and that doesn&#39;t exclude macOS systems. Installation of monit on macOS using homebrew aligns with homebrew installation guidelines. From above templates, the next example displays how easy it is to have monit up and running. &#xA;&#xA;$ brew install monit        # Installation of latest monit&#xA;$ brew services start monit # Starting latest monit as a service &#xA;Example: installing monit using homebrew&#xA;&#xA;Installing monit on a Windows machine&#xA;&#xA;Whereas macOS  systems and Linux are quite relax when it comes to interacting with processes, Windows is a beast on its own way. monit was built for nix systems but  there is no equivalent on Windows systems: Service Control Manager. It basically has the same ability to check and restart processes that are failing. &#xA;&#xA;Automated upgrades &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is not recommended to consider minor/major versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.  &#xA;&#xA;In case of a critical infrastructure piece that is monitoring, we expect breaking changes when a new version introduces a configuration setting is added, or dropped between two successive versions. Monit is a well thought software that provides backward compatibility, so chances for breaking changes between two minor versions is really minimal.  &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA;&#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install monit on various platforms. Even though configuration was beyond the scope of this article, we managed to get everyday quick refreshers out.&#xA;&#xA;Reading list and References&#xA;&#xA;upstart tutorial&#xA;Uptime&#xA;An A-Z Index of the Apple macOS command line (macOS bash) and the Apple macOS How-to guides and examples&#xA; Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #monit #y2020 ,#Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>monit</code> monitoring system on production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<p>There are a plethora of monitoring and logging solutions around the internet. This article will not focus on any of those, rather provide alternatives using tools already available in Linux/UNIX environments, that may achieve near same capabilities as any of those solutions.</p>

<p><strong>In this article you will learn about:</strong></p>

<p><strong>—</strong></p>
<ul><li>Difference between logging and monitoring</li>
<li>Tools available for logging</li>
<li>Tools available for monitoring</li>
<li>How to install monitoring and logging tools</li>
<li>How to connect end-to-end reporting for faster response times.</li></ul>

<h2 id="installing-monit-on-linux" id="installing-monit-on-linux">Installing <code>monit</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update # Fetch list of available updates
$ apt-get upgrade # Upgrades current packages
$ apt-get dist-upgrade # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-monit-on-linux-using-apt" id="installing-a-monit-on-linux-using-apt">Installing a <code>monit</code> on Linux using <code>apt</code></h3>

<h2 id="installing-monit-on-macos" id="installing-monit-on-macos">Installing <code>monit</code> on macOS</h2>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to install/uninstall things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-monit-on-a-macos-using-homebrew" id="installing-a-monit-on-a-macos-using-homebrew">Installing a <code>monit</code> on a macOS  using <code>homebrew</code></h3>

<p>It is hard to deny the supremacy of <code>monit</code> on *NIX systems, and that doesn&#39;t exclude macOS systems. Installation of <code>monit</code> on macOS using <code>homebrew</code> aligns with <code>homebrew</code> installation guidelines. From above templates, the next example displays how easy it is to have <code>monit</code> up and running.</p>

<pre><code class="language-shell">$ brew install monit        # Installation of latest monit
$ brew services start monit # Starting latest monit as a service 
</code></pre>

<p><em><em>Example</em>: installing <code>monit</code> using <code>homebrew</code></em></p>

<h2 id="installing-monit-on-a-windows-machine" id="installing-monit-on-a-windows-machine">Installing <code>monit</code> on a Windows machine</h2>

<p>Whereas macOS  systems and Linux are quite relax when it comes to interacting with processes, Windows is a beast on its own way. <code>monit</code> was built for <code>*nix</code> systems but  there is no equivalent on Windows systems: Service Control Manager. It basically has the same ability to check and restart processes that are failing.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is not recommended to consider <strong><em>minor</em></strong>/<strong><em>major</em></strong> versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.</p>

<p>In case of a critical infrastructure piece that is monitoring, we expect breaking changes when a new version introduces a configuration setting is added, or dropped between two successive versions. Monit is a well thought software that provides backward compatibility, so chances for breaking changes between two minor versions is really minimal.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>monit</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-monit-to-monitor-nodejs-application">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list-and-references" id="reading-list-and-references">Reading list and References</h2>
<ul><li><a href="http://howtonode.org/deploying-node-upstart-monit">upstart tutorial</a></li>
<li><a href="https://github.com/fzaninotto/uptime">Uptime</a></li>
<li><em><a href="https://ss64.com/osx/">An A-Z Index of the Apple macOS command line (macOS bash)</a></em> and the <em><a href="https://ss64.com/osx/syntax.html">Apple macOS How-to guides and examples</a></em>
<ul><li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:monit" class="hashtag"><span>#</span><span class="p-category">monit</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> ,<a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-monit</guid>
      <pubDate>Fri, 31 Jan 2020 22:49:49 +0000</pubDate>
    </item>
    <item>
      <title>How to install nginx</title>
      <link>https://getsimple.works/how-to-install-nginx?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install nginx non blocking single threaded multipurpose web server on development and production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link  &#xA;&#xA;Installing nginx on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update # Fetch list of available updates&#xA;$ apt-get upgrade # Upgrades current packages&#xA;$ apt-get dist-upgrade # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a nginx on Linux using apt&#xA;&#xA;Updating/Upgrading or first install of &#xA;$ sudo add-apt-repository ppa:nginx/stable&#xA;$ sudo apt-get update &#xA;$ sudo apt-get install - nginx &#xA;&#xA;To restart the service:&#xA;$ sudo service nginx restart &#xA;Example: updating PPA and installing nginx binaries&#xA;&#xA;  Adding nginx PPA in first step is only required for first installs, on a system that does not have the PPA available in the system database.  &#xA;&#xA;Installing nginx on macOS &#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install/uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a nginx on a Mac using homebrew&#xA;&#xA;$ brew install nginx@1.17.8  # as in formula@version&#xA;Example: installing nginx using homebrew&#xA;&#xA;Installing nginx on a Windows machine&#xA;&#xA;MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a nodejs environment on a Mac. This is an easy target as nginx gives windows binaries that we can download and install on a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing an nginx deployment. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is not recommended to consider minor/major versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.  &#xA;&#xA;In case of a WebServer, breaking changes may be introduced when a critical configuration setting is added, or dropped between two successive versions. &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA; &#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install nginx on various platforms. Even though configuration was beyond the scope of this article, we managed to get everyday quick refreshers out. &#xA;&#xA;Reading list &#xA;&#xA;Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nginx #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>nginx</code> non blocking single threaded multipurpose web server on development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<h2 id="installing-nginx-on-linux" id="installing-nginx-on-linux">Installing <code>nginx</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update # Fetch list of available updates
$ apt-get upgrade # Upgrades current packages
$ apt-get dist-upgrade # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-nginx-on-linux-using-apt" id="installing-a-nginx-on-linux-using-apt">Installing a <code>nginx</code> on Linux using <code>apt</code></h3>

<p>Updating/Upgrading or first install of <code>nginx</code> server can be achieved with by the following commands.</p>

<pre><code class="language-shell">$ sudo add-apt-repository ppa:nginx/stable
$ sudo apt-get update 
$ sudo apt-get install - nginx 

# To restart the service:
$ sudo service nginx restart 
</code></pre>

<p><em><em>Example</em>: updating PPA and installing <code>nginx</code> binaries</em></p>

<blockquote><p>Adding <code>nginx</code> PPA in first step is only required for first installs, on a system that does not have the PPA available in the system database.</p></blockquote>

<h2 id="installing-nginx-on-macos" id="installing-nginx-on-macos">Installing <code>nginx</code> on macOS</h2>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to install/uninstall things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using <code>homebrew</code></em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-nginx-on-a-mac-using-homebrew" id="installing-a-nginx-on-a-mac-using-homebrew">Installing a <code>nginx</code> on a Mac using <code>homebrew</code></h3>

<pre><code class="language-shell">$ brew install nginx@1.17.8  # as in &lt;formula&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: installing <code>nginx</code> using <code>homebrew</code></em></p>

<h2 id="installing-nginx-on-a-windows-machine" id="installing-nginx-on-a-windows-machine">Installing <code>nginx</code> on a Windows machine</h2>

<p>MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a <code>nodejs</code> environment on a Mac. This is an easy target as <a href="https://nginx.org/en/docs/windows.html"><code>nginx</code></a> gives windows binaries that we can download and install on a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing an <code>nginx</code> deployment. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is not recommended to consider <strong><em>minor</em></strong>/<strong><em>major</em></strong> versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.</p>

<p>In case of a WebServer, breaking changes may be introduced when a critical configuration setting is added, or dropped between two successive versions.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>nginx</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-nginx-to-run-with-a-nodejs-server">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-nginx</guid>
      <pubDate>Fri, 31 Jan 2020 22:49:00 +0000</pubDate>
    </item>
    <item>
      <title>How to install mongodb</title>
      <link>https://getsimple.works/how-to-install-mongodb?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install mongodb, one of leading noSQL databases on development and production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help those who bought the book to setup their working environment, as well as the wide audience of software developers who need same information.  &#xA;&#xA;In this article we will talk about:&#xA;&#xA;How to install mongodb on Linux, macOS and Windows.&#xA;How to stop/start automatically prior/after system restarts&#xA;&#xA;We will not talk about:&#xA;&#xA;How to configure mongodb for development and production, as that is subject of another article worth visiting. &#xA;How to manage mongodb in a production environment, either in a containerized or standalone contexts.&#xA;How to load mongodb on Docker and Kubernetes&#xA;&#xA;Installing mongodb on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update        # Fetch list of available updates&#xA;$ apt-get upgrade       # Upgrades current packages&#xA;$ apt-get dist-upgrade  # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a mongodb on Linux using apt&#xA;&#xA;Updating/Upgrading or first time fresh install of &#xA;  sudo may be skipped if the current user has permission to write and execute programs &#xA;&#xA;Add public key used by the aptitude for further updates&#xA;gnupg should be available in the system&#xA;$ apt-get install gnupg &#xA;$ wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add - &#xA;&#xA;create and add list for mongodb (version 3.6, but variations can differ from version to version, the same applies to architecture)&#xA;$ echo &#34;deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse&#34; | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list&#xA;&#xA;Updating libraries and make the actual install &#xA;$ sudo apt-get update&#xA;$ sudo apt-get install -y mongodb-org&#xA;&#xA;To install specific version(3.6.17 in our example) of mongodb, the following command helps&#xA;$ sudo apt-get install -y mongodb-org=3.6.17 mongodb-org-server=3.6.17 mongodb-org-shell=3.6.17 mongodb-org-mongos=3.6.17 mongodb-org-tools=3.6.17&#xA;Example: adding mongodb PPA binaries and installing a particular binary version&#xA;&#xA;It is always a good idea to upgrade often. Breaking changes happen on major/minor binary updates, but less likely on patch upgrades. The versions goes by pair numbers, so 3.2, 3.4, 3.6 etc. The transition that skips two version may be catastrophic. For example  upgrades from any 3.x to 3.6, for this to work, there should be upgraded to an intermediate update from 3.x to 3.4, after which the update from 3.4 to 3.6 becomes possible. &#xA;&#xA;Part 1&#xA;$ apt-cache policy mongodb-org          # Checking installed MongoDB version &#xA;$ apt-get install -y mongodb-org=3.4    # Installing 3.4 MongoDB version &#xA;&#xA;Part 2   &#xA;Running mongodb&#xA;$ sudo killall mongod &amp;&amp; sleep 3 &amp;&amp; sudo service mongod start&#xA;$ sudo service mongodb start           &#xA;&#xA;Part 3 &#xA;$ mongo                                 # Accessing to mongo CLI&#xA;&#xA;Compatible Mode&#xA;$   db.adminCommand( { setFeatureCompatibilityVersion: &#34;3.4&#34; } )  &#xA;$   exit&#xA;&#xA;Part 3 &#xA;$ sudo apt-get install -y mongodb-org=3.6   # Upgrading to latest 3.6 version &#xA;Restart Server + As in Part 2.&#xA;Example: updating mongodb binaries and upgrading to a version&#xA;&#xA;Installing mongodb on macOS &#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. We should also highlight that homebrew requires xcode to be available on the system. &#xA;&#xA;$ /usr/bin/ruby -e \&#xA;    &#34;$(curl -fsSL https://raw.githubusercontent.com \&#xA;    /Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install and uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a mongodb on a Mac using homebrew&#xA;&#xA;$ brew tap mongodb/brew &#xA;$ brew install mongodb-community@3.6&#xA;$ brew services start mongodb-community@3.6 # start mongodb as a mac service &#xA;Example: Install and running mongodb as a macOS service&#xA;&#xA;  Caveats ~ We have extra steps to make in order to start/stop automatically when the system goes up/down. This step is vital when doing development on macOS , which does not necessarily needs Linux production bound task runners.&#xA;&#xA;To have launchd start mongodb at login:&#xA;$ ln -s /usr/local/opt/mongodb/.plist ~/Library/LaunchAgents/&#xA;&#xA;Then to load mongodb now:&#xA;$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist&#xA;&#xA;To unregister and stop the service, use the following command&#xA;$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist&#xA;&#xA;When not want/need launchctl this command works fine&#xA;$ mongod &#xA;Example: Stop/Start when the system stops/starts&#xA;&#xA;Installing mongodb on a Windows machine&#xA;&#xA;Whereas MacOs, and most Linux distributions, come with Python and Ruby already enabled, It takes extra mile for Windows to make those two languages available. We have to stress on the fact that those two languages are somehow required to deploy a mongodb environment on most platforms, especially when working with nodejs. &#xA;&#xA;The bright side of this story is that mongodb provides windows binaries that we can downloaded and installed in a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a mongodb instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is not recommended to consider minor/major versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.  &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA;&#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install mongodb on various platforms. Even though configuration was beyond the scope of this article*, we managed to get everyday quick refreshers out in the article. There are areas we wish we added more coverage, probably not on the first version of this article. &#xA;&#xA;  Some of other places where people are wondering how to install mongodb on various platforms include, but not limited to Quora, StackOverflow and Reddit. &#xA;&#xA;Reading list &#xA;&#xA;Documentation on how to Install mongodb on Ubuntu&#xA; An A-Z Index of the Apple macOS command line (macOS bash) and the Apple macOS How-to guides and examples, launchd&#xA; The answer to two questions: 1) How to know package version and 2) How to install a specific Package with aptitude. &#xA;Performing Automated In-place Cluster Updates, on Google Cloud Platform: Auto-upgrading nodes&#xA;More on configuring unattended-upgrades are in these articles: Automatic Updates,  How to Enable Unattended Upgrades on Ubuntu/Debian and How to Setup Automatic Security Updates on Ubuntu 16.04&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #mongodb #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>mongodb</code>, one of leading noSQL databases on development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help those who bought the book to setup their working environment, as well as the wide audience of software developers who need same information.</p></blockquote>

<p><strong>In this article we will talk about</strong>:</p>

<p><strong>__</strong></p>
<ul><li>How to install <code>mongodb</code> on Linux, macOS and Windows.</li>
<li>How to stop/start automatically prior/after system restarts</li></ul>

<p><strong>We will not talk about</strong>:</p>

<p><strong>__</strong></p>
<ul><li>How to configure <code>mongodb</code> for development and production, as that is subject of another article worth visiting.</li>
<li>How to manage <code>mongodb</code> in a production environment, either in a containerized or standalone contexts.</li>
<li>How to load <code>mongodb</code> on Docker and Kubernetes</li></ul>

<h2 id="installing-mongodb-on-linux" id="installing-mongodb-on-linux">Installing <code>mongodb</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update        # Fetch list of available updates
$ apt-get upgrade       # Upgrades current packages
$ apt-get dist-upgrade  # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-mongodb-on-linux-using-apt" id="installing-a-mongodb-on-linux-using-apt">Installing a <code>mongodb</code> on Linux using <code>apt</code></h3>

<p>Updating/Upgrading or first time fresh install of <code>mongodb</code> can follow next scripts.</p>

<blockquote><p><strong><em><code>sudo</code></em></strong> may be skipped if the current user has permission to write and execute programs</p></blockquote>

<pre><code class="language-shell"># Add public key used by the aptitude for further updates
# gnupg should be available in the system
$ apt-get install gnupg 
$ wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add - 

# create and add list for mongodb (version 3.6, but variations can differ from version to version, the same applies to architecture)
$ echo &#34;deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse&#34; | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

# Updating libraries and make the actual install 
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org

# To install specific version(3.6.17 in our example) of mongodb, the following command helps
$ sudo apt-get install -y mongodb-org=3.6.17 mongodb-org-server=3.6.17 mongodb-org-shell=3.6.17 mongodb-org-mongos=3.6.17 mongodb-org-tools=3.6.17
</code></pre>

<p><em><em>Example</em>: adding <code>mongodb</code> PPA binaries and installing a particular binary version</em></p>

<p>It is always a good idea to upgrade often. Breaking changes happen on major/minor binary updates, but less likely on patch upgrades. The versions goes by pair numbers, so 3.2, 3.4, 3.6 etc. The transition that skips two version may be catastrophic. For example  upgrades from any 3.x to 3.6, for this to work, there should be upgraded to an intermediate update from 3.x to 3.4, after which the update from 3.4 to 3.6 becomes possible.</p>

<pre><code class="language-shell"># Part 1
$ apt-cache policy mongodb-org          # Checking installed MongoDB version 
$ apt-get install -y mongodb-org=3.4    # Installing 3.4 MongoDB version 

# Part 2   
# Running mongodb
$ sudo killall mongod &amp;&amp; sleep 3 &amp;&amp; sudo service mongod start
$ sudo service mongodb start           

# Part 3 
$ mongo                                 # Accessing to mongo CLI

# Compatible Mode
$ &gt; db.adminCommand( { setFeatureCompatibilityVersion: &#34;3.4&#34; } )  
$ &gt; exit

# Part 3 
$ sudo apt-get install -y mongodb-org=3.6   # Upgrading to latest 3.6 version 
# Restart Server + As in Part 2.
</code></pre>

<p><em><em>Example</em>: updating <code>mongodb</code> binaries and upgrading to a version</em></p>

<h2 id="installing-mongodb-on-macos" id="installing-mongodb-on-macos">Installing <code>mongodb</code> on macOS</h2>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze. We should also highlight that <code>homebrew</code> requires <code>xcode</code> to be available on the system.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e \
    &#34;$(curl -fsSL https://raw.githubusercontent.com \
    /Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to <strong><em>install</em></strong> and <strong><em>uninstall</em></strong> things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-mongodb-on-a-mac-using-homebrew" id="installing-a-mongodb-on-a-mac-using-homebrew">Installing a <code>mongodb</code> on a Mac using <code>homebrew</code></h3>

<pre><code class="language-shell">$ brew tap mongodb/brew 
$ brew install mongodb-community@3.6
$ brew services start mongodb-community@3.6 # start mongodb as a mac service 
</code></pre>

<p><em><em>Example</em>: Install and running <code>mongodb</code> as a macOS service</em></p>

<blockquote><p><strong><em>Caveats</em></strong> ~ We have extra steps to make in order to start/stop automatically when the system goes up/down. This step is vital when doing development on macOS , which does not necessarily needs Linux production bound task runners.</p></blockquote>

<pre><code class="language-shell"># To have launchd start mongodb at login:
$ ln -s /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/

# Then to load mongodb now:
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

# To unregister and stop the service, use the following command
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

# When not want/need launchctl this command works fine
$ mongod 
</code></pre>

<p><em><em>Example</em>: Stop/Start when the system stops/starts</em></p>

<h2 id="installing-mongodb-on-a-windows-machine" id="installing-mongodb-on-a-windows-machine">Installing <code>mongodb</code> on a Windows machine</h2>

<p>Whereas MacOs, and most Linux distributions, come with Python and Ruby already enabled, It takes extra mile for Windows to make those two languages available. We have to stress on the fact that those two languages are somehow required to deploy a <code>mongodb</code> environment on most platforms, especially when working with <code>nodejs</code>.</p>

<p>The bright side of this story is that <a href="https://www.mongodb.com/download-center/community"><code>mongodb</code></a> provides windows binaries that we can downloaded and installed in a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>mongodb</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is not recommended to consider <strong><em>minor</em></strong>/<strong><em>major</em></strong> versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>mongodb</code> on various platforms. Even though <em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-mongodb-as-a-database-server-for-nodejs-project">configuration was beyond the scope of this article</a></em>, we managed to get everyday quick refreshers out in the article. There are areas we wish we added more coverage, probably not on the first version of this article.</p>

<blockquote><p>Some of other places where people are wondering how to install <code>mongodb</code> on various platforms include, but not limited to <a href="https://www.quora.com/search?q=install+mongodb">Quora</a>, <a href="https://stackoverflow.com/search?q=install+mongodb">StackOverflow</a> and <a href="https://www.reddit.com/search?q=install%20mongodb&amp;restrict_sr=">Reddit</a>.</p></blockquote>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li>Documentation on how to <a href="https://docs.mongodb.com/v3.6/tutorial/install-mongodb-on-ubuntu/">Install <code>mongodb</code> on Ubuntu</a>
<ul><li><em><a href="https://ss64.com/osx/">An A-Z Index of the Apple macOS command line (macOS bash)</a></em> and the <em><a href="https://ss64.com/osx/syntax.html">Apple macOS How-to guides and examples</a></em>, <a href="https://www.launchd.info">launchd</a></li>
<li><a href="https://askubuntu.com/a/428778">The answer to two questions</a>: 1) <strong><em>How to know package version</em></strong> and 2) <strong><em>How to install a specific Package with aptitude</em></strong>.</li></ul></li>
<li><a href="https://docs.openshift.com/container-platform/3.6/install_config/upgrading/automated_upgrades.html">Performing Automated In-place Cluster Updates</a>, on Google Cloud Platform: <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-upgrades">Auto-upgrading nodes</a></li>
<li>More on configuring unattended-upgrades are in these articles: <a href="https://help.ubuntu.com/lts/serverguide/automatic-updates.html">Automatic Updates</a>,  <a href="https://haydenjames.io/how-to-enable-unattended-upgrades-on-ubuntu-debian/">How to Enable Unattended Upgrades on Ubuntu/Debian</a> and <a href="https://www.howtoforge.com/tutorial/how-to-setup-automatic-security-updates-on-ubuntu-1604/">How to Setup Automatic Security Updates on Ubuntu 16.04</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:mongodb" class="hashtag"><span>#</span><span class="p-category">mongodb</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-mongodb</guid>
      <pubDate>Fri, 31 Jan 2020 22:47:36 +0000</pubDate>
    </item>
    <item>
      <title>How to install redis</title>
      <link>https://getsimple.works/how-to-install-redis?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install redis key/value data store on development and production servers.&#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link  &#xA;&#xA;Installing redis on Linux &#xA;&#xA;It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:&#xA;&#xA;$ apt-get update # Fetch list of available updates&#xA;$ apt-get upgrade # Upgrades current packages&#xA;$ apt-get dist-upgrade # Installs only new updates&#xA;Example: updating aptitude binaries&#xA;&#xA;At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.&#xA;&#xA;Installing a redis on Linux using apt&#xA;&#xA;Updating   The &#xA;Installing binaries &#xA;$ curl -O http://download.redis.io/redis-stable.tar.gz&#xA;$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable &#xA;$ make &amp;&amp; make install&#xA;Configure redis - for first time installs &#xA;&#xA;Install via PPA &#xA;$ apt-get install -y python-software-properties #provides access to add-apt-repository &#xA;$ apt-get install -y software-properties-common python-software-properties&#xA;&#xA;@link https://packages.ubuntu.com/bionic/redis &#xA;$ add-apt-repository -y ppa:bionic/redis # Alternatively rwky/redis&#xA;$ apt-get update&#xA;$ apt-get install -y redis-server&#xA;&#xA;Starting Redis for development on Mac&#xA;$ redis-server /usr/local/etc/redis.conf &#xA;Example: installing redis binaries with aptitude&#xA;&#xA;Installing redis on a Mac system &#xA; &#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install/uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a redis on a macOS  using curl&#xA;&#xA;Installing redis via a curl command is not that different as on Linux system. The following instructions can accomplish the installation. &#xA;&#xA;Installing binaries &#xA;$ curl -O http://download.redis.io/redis-stable.tar.gz&#xA;$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable &#xA;$ make &amp;&amp; make install&#xA;Configure redis - for first time installs &#xA;Example: install redis binaries using curl and make&#xA;&#xA;Installing a redis on a Mac using homebrew&#xA;&#xA;$ brew install redis        # Installation following formula@version template &#xA;$ brew services start redis # Starting redis as a service  &#xA;&#xA;Alternatively start as usual &#xA;$ redis-server /usr/local/etc/redis.conf&#xA;Running on port: 6379&#xA;Example: install redis binaries using homebrew&#xA;&#xA;Installing redis on a Windows machine&#xA;&#xA;MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a nodejs environment. This is an easy target as redis gives windows binaries that we can download and install on a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a mongodb instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is recommended that the only pair minor versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated. &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf&#xA;&#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install redis on various platforms. Even though configuration was beyond the scope of this article, we managed to get everyday quick refreshers out. &#xA;&#xA;Reading list &#xA;&#xA;Install and config Redis on Mac OS X via Homebrew&#xA;Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nvm #n #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install <code>redis</code> key/value data store on development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<h2 id="installing-redis-on-linux" id="installing-redis-on-linux">Installing <code>redis</code> on Linux</h2>

<p>It is always a good idea to update the system before start working. There is no exception, even when a daily task updates automatically binaries. That can be achieved on Ubuntu and Aptitude enabled systems as following:</p>

<pre><code class="language-shell">$ apt-get update # Fetch list of available updates
$ apt-get upgrade # Upgrades current packages
$ apt-get dist-upgrade # Installs only new updates
</code></pre>

<p><em><em>Example</em>: updating aptitude binaries</em></p>

<p>At this point most of packages should be installed or upgraded. Except Packages whose PPA have been removed or not available in the registry. Installing software can be done by installing binaries, or using Ubuntu package manager.</p>

<h3 id="installing-a-redis-on-linux-using-apt" id="installing-a-redis-on-linux-using-apt">Installing a <code>redis</code> on Linux using <code>apt</code></h3>

<p>Updating <code>redis</code> – In case the above global update didn&#39;t take effect.
  The <code>-y</code> option passes YES, so there are no prompt for <code>Y/N?</code> while installing libraries.</p>

<pre><code class="language-shell"># Installing binaries 
$ curl -O http://download.redis.io/redis-stable.tar.gz
$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable 
$ make &amp;&amp; make install
# Configure redis - for first time installs 

# Install via PPA 
$ apt-get install -y python-software-properties #provides access to add-apt-repository 
$ apt-get install -y software-properties-common python-software-properties

# @link https://packages.ubuntu.com/bionic/redis 
$ add-apt-repository -y ppa:bionic/redis # Alternatively rwky/redis
$ apt-get update
$ apt-get install -y redis-server

# Starting Redis for development on Mac
$ redis-server /usr/local/etc/redis.conf 
</code></pre>

<p><em><em>Example</em>: installing <code>redis</code> binaries with aptitude</em></p>

<h2 id="installing-redis-on-a-mac-system" id="installing-redis-on-a-mac-system">Installing <code>redis</code> on a Mac system</h2>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to install/uninstall things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-redis-on-a-macos-using-curl" id="installing-a-redis-on-a-macos-using-curl">Installing a <code>redis</code> on a macOS  using <code>curl</code></h3>

<p>Installing <code>redis</code> via a <code>curl</code> command is not that different as on Linux system. The following instructions can accomplish the installation.</p>

<pre><code class="language-shell"># Installing binaries 
$ curl -O http://download.redis.io/redis-stable.tar.gz
$ tar xzvf redis-stable.tar.gz &amp;&amp; cd redis-stable 
$ make &amp;&amp; make install
# Configure redis - for first time installs 
</code></pre>

<p><em><em>Example</em>: install <code>redis</code> binaries using <code>curl</code> and <code>make</code></em></p>

<h3 id="installing-a-redis-on-a-mac-using-homebrew" id="installing-a-redis-on-a-mac-using-homebrew">Installing a <code>redis</code> on a Mac using <code>homebrew</code></h3>

<pre><code class="language-shell">$ brew install redis        # Installation following &lt;formula&gt;@&lt;version&gt; template 
$ brew services start redis # Starting redis as a service  

# Alternatively start as usual 
$ redis-server /usr/local/etc/redis.conf
# Running on port: 6379
</code></pre>

<p><em><em>Example</em>: install <code>redis</code> binaries using <code>homebrew</code></em></p>

<h2 id="installing-redis-on-a-windows-machine" id="installing-redis-on-a-windows-machine">Installing <code>redis</code> on a Windows machine</h2>

<p>MacOs comes with Python and Ruby already enabled, these two languages are somehow required to run successfully a <code>nodejs</code> environment. This is an easy target as <a href="https://redis.io/download"><code>redis</code></a> gives windows binaries that we can download and install on a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>mongodb</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is recommended that the only pair <strong><em>minor</em></strong> versions be considered for version upgrades. This is because minor versions, as well as major versions, are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches do not introduce breaking changes. Those can therefore be automated.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>redis</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-redis-to-run-with-a-nodejs-server">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li><a href="https://medium.com/@petehouston/install-and-config-redis-on-mac-os-x-via-homebrew-eb8df9a4f298">Install and config Redis on Mac OS X via Homebrew</a></li>
<li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nvm" class="hashtag"><span>#</span><span class="p-category">nvm</span></a> <a href="https://getsimple.works/tag:n" class="hashtag"><span>#</span><span class="p-category">n</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-redis</guid>
      <pubDate>Fri, 31 Jan 2020 22:45:40 +0000</pubDate>
    </item>
    <item>
      <title>How to install nodejs</title>
      <link>https://getsimple.works/how-to-install-nodejs?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This article revisits essentials on how to install a nodejs environment, on both development and production servers. &#xA;&#xA;  This article has complementary materials to the Testing nodejs Applications book. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  Testing Nodejs Applications Book Cover&#xA;You can grab a copy of this book on this link  &#xA;&#xA;Installing nodejs on Linux &#xA;&#xA;When running aptitude, or similar package management tools, installing nodejs becomes quite like installing any other program. The following commands are the ones most people tend to use. &#xA;&#xA;Installing a nodejs on Linux using apt&#xA;&#xA;Challenge using this strategy, is to make sure we have nodejs in our PPA database.&#xA;&#xA;Adding and using nodejs from individual PPAs &#xA;$ sudo add-apt-repository ppa:chris-lea/nodejs&#xA;$ sudo apt-get update&#xA;$ sudo apt-get install -y nodejs&#xA;&#xA;Removing Chriss Lea PPA before using NodeSource PPA &#xA;# @link https://github.com/nodesource/distributions#manual-installation&#xA;$ sudo add-apt-repository -y -r ppa:chris-lea/nodejs&#xA;$ sudo rm -f /etc/apt/sources.list.d/chris-lea-nodejs-.list&#xA;$ sudo rm -f /etc/apt/sources.list.d/chris-lea-nodejs-.list.save&#xA;&#xA;Adding and using NodeSource distribution &#xA;@link https://github.com/nodesource/distributions &#xA;$ curl -sL https://deb.nodesource.com/setup10.x | sudo -E bash -&#xA;Alternatively &#xA;$ curl -sL https://deb.nodesource.com/setup | sudo bash -&#xA;$ sudo apt-get install -y nodejs&#xA;Example: install nodejs binaries aptitude&#xA;&#xA;Once we have nodejs to be recognized by aptitude, most operations becomes a little more familiar. Normally running apt-get upgrade should upgrade all binaries including nodejs. We should mention that updating nodejs also updates npm. &#xA;&#xA;Installing a nodejs on Linux using nvm&#xA;&#xA;When we want to test an application against a particular version of nodejs, the environment we work in should be able to manage multiple versions of nodejs. That is where tools such as nvm come into play. &#xA;&#xA;To make the tool work, we will have to have nodejs installed on our work environment. The second step will be to download and install nvm to our work environment. After installation, we can use tools provided by the nvm to install and toggle a specific version. &#xA;&#xA;$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash&#xA;Or &#xA;$ wget https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash&#xA;Install a particular nodejs version&#xA;$ nvm install vMajor.Minor.Patch&#xA;toggle a particular nodejs version&#xA;$ nvm use  vMajor.Minor.Patch&#xA;execture code with a particular nodejs version &#xA;$ nvm run  vMajor.Minor.Patch /path/to/server.js&#xA;uninstall a particular nodejs version&#xA;$ nvm uninstall  vMajor.Minor.Patch&#xA;Example: working with nvm tool&#xA;&#xA;An approach a bit similar to this is available for yet another nodejs version manager known under pseudonym n&#xA;&#xA;Installing nodejs on macOS &#xA;&#xA;It is possible to download and install nodejs manually, with ready to use installer. However, when wanting to tuning nodejs environment at our taste, messing with methods and other tools described below becomes a must. &#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation on macOS a breeze. We should also highlight that homebrew requires xcode to be available on the system. &#xA;&#xA;$ /usr/bin/ruby -e \&#xA;    &#34;$(curl -fsSL https://raw.githubusercontent.com \&#xA;    /Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;Generally speaking, this is how to install and uninstall things with brew &#xA;&#xA;$ brew install wget &#xA;$ brew uninstall wget &#xA;Example: installing/uninstalling wget binaries using homebrew&#xA;&#xA;  We have to to stress on the fact that Homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use homebrew package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help. &#xA;&#xA;$ brew outdated                   # lists all outdated packages&#xA;$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.&#xA;&#xA;$ brew upgrade                    # Upgrades all things on the system&#xA;$ brew update                     # Updates all outdated + brew itself&#xA;$ brew update formula           # Updates one formula&#xA;&#xA;$ brew install formula@version    # Installs formula at a particular version.&#xA;$ brew tap formular@version/brew  # Installs formular from third party repository&#xA;&#xA;untap/re-tap a repo when previous installation failed&#xA;$ brew untap formular &amp;&amp; brew tap formula   &#xA;$ brew services start formular@version&#xA;Example: key commands to work with homebrew cli&#xA;&#xA;  For more informations, visit: Homebrew ~ FAQ.&#xA;&#xA;Installing a nodejs on a macOS  using curl&#xA;&#xA;nodejs installation guide suggests this alternative for the MacOs. However, we have to customize a download directory, the version, and installation directory. &#xA;&#xA;$ curl &#34;https://nodejs.org/dist/latest/node-${VERSION:-$(wget \&#xA;    -qO- https://nodejs.org/dist/latest/ | \&#xA;    sed -nE &#39;s|.  node-(.)\.pkg/a.|\1|p&#39;)}.pkg&#34;   \&#xA;    &#34;$HOME/Downloads/node-latest.pkg&#34; &amp;&amp; sudo installer \&#xA;    -store -pkg &#34;$HOME/Downloads/node-latest.pkg&#34; -target \&#xA;    &#34;/&#34;&#xA;Example: installation instruction as provided by nodejs&#xA;&#xA;Using homebrew, as demo-ed in next paragraph, may be the most popular approach to install nodejs version on a macOS  machine. &#xA;&#xA;Installing a nodejs on a Mac using homebrew&#xA;&#xA;In case homebrew is not already available on your mac, this is how to get one up and running. On its own, homebrew depends on ruby runtime to be available. &#xA;&#xA;  homebrew is a package manager and software installation tool that makes most developer tools installation a breeze. &#xA;&#xA;$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;&#xA;Example: installation instruction as provided by brew.sh&#xA;&#xA;In case the homebrew is already available, it is a good practice to update it before adding new software. In the next code sample, we install some tools such as wget, sometimes useful to download binaries.&#xA;&#xA;how to install things with brew &#xA;&#xA;$ brew install nodejs  &#xA;Example: install nodejs binaries using homebrew&#xA;&#xA;After installation, add binary to the PATH [ /usr/local/share/npm/bin ],  $ nano /etc/paths, append the path /usr/local/share/npm/bin at the end of the file. &#xA;&#xA;  homebrew installs packages to their own directory and then symlinks their files into /usr/local.&#xA;&#xA;Installing nodejs on a Windows machine&#xA;&#xA;MacOs and most Linux distributions come with Python and Ruby already enabled. These two languages are somehow required to run successfully a nodejs environment on any server. This is an easy target as nodejs gives windows binaries that we can download and install on a couple of clicks.&#xA;&#xA;Automated upgrades &#xA;&#xA;Before we dive into automatic upgrades, we should consider nuances associated to managing a nodejs instance. The updates fall into two major, quite interesting, categories: patch updates and version upgrades. &#xA;&#xA;Following the SemVer ~ aka Semantic Versioning standard, it is not recommended to consider minor/major versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.  &#xA;&#xA;  We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches. &#xA;&#xA;In the context of Linux, we will use the unattended-upgrades package to do the work. &#xA;&#xA;$ apt-get install unattended-upgrades apticron&#xA;Example: install unattended-upgrades&#xA;&#xA;Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.&#xA;&#xA;Unattended-Upgrade::Allowed-Origins {&#xA;//  &#34;${distroid}:${distrocodename}&#34;;&#xA;    &#34;${distroid}:${distrocodename}-security&#34;; # upgrading security patches only &#xA;//   &#34;${distroid}:${distrocodename}-updates&#34;;  &#xA;//  &#34;${distroid}:${distrocodename}-proposed&#34;;&#xA;//  &#34;${distroid}:${distrocodename}-backports&#34;;&#xA;};&#xA;&#xA;Unattended-Upgrade::Package-Blacklist {&#xA;    &#34;vim&#34;;&#xA;};&#xA;Example: fine-tune the blacklist and whitelist in /etc/apt/apt.conf.d/50unattended-upgrades&#xA;&#xA;The next step is necessary to make sure  unattended-upgrades download, install and cleanups tasks have a default period: once, twice a day or a week. &#xA;&#xA;APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day&#xA;APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day&#xA;APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week&#xA;APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day&#xA;Example: tuning the tasks parameter /etc/apt/apt.conf.d/20auto-upgrades&#xA;&#xA;This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool apticron in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all. &#xA;&#xA;EMAIL=&#34;email@host.tld&#34;&#xA;Example: tuning reporting tasks email parameter /etc/apticron/apticron.conf_&#xA; &#xA;Conclusion&#xA;&#xA;In this article we revisited ways to install nodejs on various platforms. Even though configuration was beyond the scope of this article*, we managed to get everyday quick refreshers out. &#xA;&#xA;Reading list &#xA;&#xA;Manual Installation ~ NodeSource&#xA;Distributions ~ NodeSource&#xA;Configuring nodejs applications&#xA;&#xA;#nodejs #homebrew #UnattendedUpgrades #nvm #n #y2020 #Jan2020 #HowTo #ConfiguringNodejsApplications #tdd #TestingNodejsApplications&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>This article revisits essentials on how to install a <code>nodejs</code> environment, on both development and production servers.</p>

<blockquote><p>This article has complementary materials to the <strong><em><a href="http://bit.ly/2ZFJytb">Testing <code>nodejs</code> Applications book</a></em></strong>. However, the article is designed to help both those who already bought the book, as well as the wide audience of software developers  to setup working environment.  <a href="http://bit.ly/2ZFJytb"><img src="https://snap.as/a/42OS2vs.png" alt="Testing Nodejs Applications Book Cover"/></a>
<strong><em><a href="http://bit.ly/2ZFJytb">You can grab a copy of this book on this link</a></em></strong></p></blockquote>

<h2 id="installing-nodejs-on-linux" id="installing-nodejs-on-linux">Installing <code>nodejs</code> on Linux</h2>

<p>When running aptitude, or similar package management tools, installing <code>nodejs</code> becomes quite like installing any other program. The following commands are the ones most people tend to use.</p>

<h3 id="installing-a-nodejs-on-linux-using-apt" id="installing-a-nodejs-on-linux-using-apt">Installing a <code>nodejs</code> on Linux using <code>apt</code></h3>

<p>Challenge using this strategy, is to make sure we have <code>nodejs</code> in our PPA database.</p>

<pre><code class="language-shell"># Adding and using nodejs from individual PPAs 
$ sudo add-apt-repository ppa:chris-lea/nodejs
$ sudo apt-get update
$ sudo apt-get install -y nodejs


# Removing Chriss Lea PPA before using NodeSource PPA 
# @link https://github.com/nodesource/distributions#manual-installation
$ sudo add-apt-repository -y -r ppa:chris-lea/nodejs
$ sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
$ sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save


# Adding and using NodeSource distribution 
# @link https://github.com/nodesource/distributions 
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
# Alternatively 
$ curl -sL https://deb.nodesource.com/setup | sudo bash -
$ sudo apt-get install -y nodejs
</code></pre>

<p><em><em>Example</em>: install <code>nodejs</code> binaries aptitude</em></p>

<p>Once we have <code>nodejs</code> to be recognized by aptitude, most operations becomes a little more familiar. Normally running <code>apt-get upgrade</code> should upgrade all binaries including <code>nodejs</code>. We should mention that updating <code>nodejs</code> also updates <code>npm</code>.</p>

<h3 id="installing-a-nodejs-on-linux-using-nvm" id="installing-a-nodejs-on-linux-using-nvm">Installing a <code>nodejs</code> on Linux using <code>nvm</code></h3>

<p>When we want to test an application against a particular version of <code>nodejs</code>, the environment we work in should be able to manage multiple versions of <code>nodejs</code>. That is where tools such as nvm come into play.</p>

<p>To make the tool work, we will have to have <code>nodejs</code> installed on our work environment. The second step will be to download and install <code>nvm</code> to our work environment. After installation, we can use tools provided by the nvm to install and toggle a specific version.</p>

<pre><code class="language-shell">$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# Or 
$ wget https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# Install a particular nodejs version
$ nvm install v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
# toggle a particular nodejs version
$ nvm use  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
# execture code with a particular nodejs version 
$ nvm run  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt; /path/to/server.js
# uninstall a particular nodejs version
$ nvm uninstall  v&lt;Major&gt;.&lt;Minor&gt;.&lt;Patch&gt;
</code></pre>

<p><em><em>Example:</em> working with <a href="https://github.com/nvm-sh/nvm"><code>nvm</code></a> tool</em></p>

<p>An approach a bit similar to this is available for yet another <code>nodejs</code> version manager known under pseudonym <a href="https://www.npmjs.com/package/n"><code>n</code></a></p>

<h2 id="installing-nodejs-on-macos" id="installing-nodejs-on-macos">Installing <code>nodejs</code> on macOS</h2>

<p>It is possible to download and install <code>nodejs</code> manually, with ready to use installer. However, when wanting to tuning <code>nodejs</code> environment at our taste, messing with methods and other tools described below becomes a must.</p>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on <code>ruby</code> runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation on macOS a breeze. We should also highlight that <code>homebrew</code> requires <code>xcode</code> to be available on the system.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e \
    &#34;$(curl -fsSL https://raw.githubusercontent.com \
    /Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>Generally speaking, this is how to <strong><em>install</em></strong> and <strong><em>uninstall</em></strong> things with <code>brew</code></p>

<pre><code class="language-shell">$ brew install wget 
$ brew uninstall wget 
</code></pre>

<p><em><em>Example</em>: installing/uninstalling <code>wget</code> binaries using homebrew</em></p>

<blockquote><p>We have to to stress on the fact that <a href="https://brew.sh/">Homebrew</a> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<p>It is always a good idea to update the system before start working. And that, even when we have a daily task that automatically updates the system for us. macOS  can use <code>homebrew</code> package manager on maintenance matters. To update/upgrade or check outdated packages, following commands would help.</p>

<pre><code class="language-shell">$ brew outdated                   # lists all outdated packages
$ brew cleanup -n                 # visualize the list of things are going to be cleaned up.

$ brew upgrade                    # Upgrades all things on the system
$ brew update                     # Updates all outdated + brew itself
$ brew update &lt;formula&gt;           # Updates one formula

$ brew install &lt;formula@version&gt;    # Installs &lt;formula&gt; at a particular version.
$ brew tap &lt;formular@version&gt;/brew  # Installs &lt;formular&gt; from third party repository

# untap/re-tap a repo when previous installation failed
$ brew untap &lt;formular&gt; &amp;&amp; brew tap &lt;formula&gt;   
$ brew services start &lt;formular&gt;@&lt;version&gt;
</code></pre>

<p><em><em>Example</em>: key commands to work with <code>homebrew</code> cli</em></p>

<blockquote><p>For more informations, visit: <a href="https://docs.brew.sh/FAQ">Homebrew ~ FAQ</a>.</p></blockquote>

<h3 id="installing-a-nodejs-on-a-macos-using-curl" id="installing-a-nodejs-on-a-macos-using-curl">Installing a <code>nodejs</code> on a macOS  using <code>curl</code></h3>

<p><code>nodejs</code> installation guide suggests this alternative for the MacOs. However, we have to customize a download directory, the version, and installation directory.</p>

<pre><code class="language-shell">$ curl &#34;https://nodejs.org/dist/latest/node-${VERSION:-$(wget \
    -qO- https://nodejs.org/dist/latest/ | \
    sed -nE &#39;s|.*&gt;node-(.*)\.pkg&lt;/a&gt;.*|\1|p&#39;)}.pkg&#34; &gt; \
    &#34;$HOME/Downloads/node-latest.pkg&#34; &amp;&amp; sudo installer \
    -store -pkg &#34;$HOME/Downloads/node-latest.pkg&#34; -target \
    &#34;/&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://nodejs.org/en/download/package-manager/"><code>nodejs</code></a></em></p>

<p>Using <code>homebrew</code>, as demo-ed in next paragraph, may be the most popular approach to install <code>nodejs</code> version on a macOS  machine.</p>

<h3 id="installing-a-nodejs-on-a-mac-using-homebrew" id="installing-a-nodejs-on-a-mac-using-homebrew">Installing a <code>nodejs</code> on a Mac using <code>homebrew</code></h3>

<p>In case <code>homebrew</code> is not already available on your mac, this is how to get one up and running. On its own, <code>homebrew</code> depends on ruby runtime to be available.</p>

<blockquote><p><code>homebrew</code> is a package manager and software installation tool that makes most developer tools installation a breeze.</p></blockquote>

<pre><code class="language-shell">$ /usr/bin/ruby -e &#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&#34;
</code></pre>

<p><em><em>Example:</em> installation instruction as provided by <a href="https://brew.sh/">brew.sh</a></em></p>

<p>In case the <code>homebrew</code> is already available, it is a good practice to update it before adding new software. In the next code sample, we install some tools such as <code>wget</code>, sometimes useful to download binaries.</p>

<p>how to install things with brew</p>

<pre><code class="language-shell">$ brew install nodejs  
</code></pre>

<p><em><em>Example</em>: install <code>nodejs</code> binaries using <code>homebrew</code></em></p>

<p>After installation, add binary to the PATH [ <code>/usr/local/share/npm/bin</code> ],  <code>$ nano /etc/paths</code>, append the path <code>/usr/local/share/npm/bin</code> at the end of the file.</p>

<blockquote><p><code>homebrew</code> installs packages to their own directory and then symlinks their files into <code>/usr/local</code>.</p></blockquote>

<h2 id="installing-nodejs-on-a-windows-machine" id="installing-nodejs-on-a-windows-machine">Installing <code>nodejs</code> on a Windows machine</h2>

<p>MacOs and most Linux distributions come with Python and Ruby already enabled. These two languages are somehow required to run successfully a <code>nodejs</code> environment on any server. This is an easy target as <a href="https://nodejs.org/en/download/"><code>nodejs</code></a> gives windows binaries that we can download and install on a couple of clicks.</p>

<h2 id="automated-upgrades" id="automated-upgrades">Automated upgrades</h2>

<p>Before we dive into automatic upgrades, we should consider nuances associated to managing a <code>nodejs</code> instance. The updates fall into two major, quite interesting, categories: <strong><em>patch</em></strong> updates and <strong><em>version upgrades</em></strong>.</p>

<p>Following the <a href="https://semver.org/">SemVer ~ <em>aka Semantic Versioning</em></a> standard, it is not recommended to consider <strong><em>minor</em></strong>/<strong><em>major</em></strong> versions for automated upgrades. One of the reasons being that these versions are subject to introducing breaking changes or incompatibility between two versions.  On the other hand, patches are less susceptible to introduce breaking changes, whence ideal candidates for automated upgrades. Another among other reasons, being that security fixes are released as patches to a minor version.</p>

<blockquote><p>We should highlight that it is always better to upgrade at deployment time. The process is even easier in containerized context. We should also automate only patches, to avoid to miss security patches.</p></blockquote>

<p>In the context of Linux, we will use the <strong><em>unattended-upgrades</em></strong> package to do the work.</p>

<pre><code class="language-shell">$ apt-get install unattended-upgrades apticron
</code></pre>

<p><em><em>Example</em>: install unattended-upgrades</em></p>

<p>Two things to fine-tune to make this solution work are: to enable a blacklist of packages we do not to automatically update, and two, to enable particular packages we would love to update on a periodical basis. That is compiled in the following shell scripts.</p>

<pre><code class="language-shell">Unattended-Upgrade::Allowed-Origins {
//  &#34;${distro_id}:${distro_codename}&#34;;
    &#34;${distro_id}:${distro_codename}-security&#34;; # upgrading security patches only 
//   &#34;${distro_id}:${distro_codename}-updates&#34;;  
//  &#34;${distro_id}:${distro_codename}-proposed&#34;;
//  &#34;${distro_id}:${distro_codename}-backports&#34;;
};

Unattended-Upgrade::Package-Blacklist {
    &#34;vim&#34;;
};
</code></pre>

<p><em><em>Example</em>: fine-tune the blacklist and whitelist in <code>/etc/apt/apt.conf.d/50unattended-upgrades</code></em></p>

<p>The next step is necessary to make sure  <strong><em>unattended-upgrades</em></strong> download, install and cleanups tasks have a default period: once, twice a day or a week.</p>

<pre><code class="language-shell">APT::Periodic::Update-Package-Lists &#34;1&#34;;            # Updates package list once a day
APT::Periodic::Download-Upgradeable-Packages &#34;1&#34;;   # download upgrade candidates once a day
APT::Periodic::AutocleanInterval &#34;7&#34;;               # clean week worth of unused packages once a week
APT::Periodic::Unattended-Upgrade &#34;1&#34;;              # install downloaded packages once a day
</code></pre>

<p><em><em>Example</em>: tuning the tasks parameter <code>/etc/apt/apt.conf.d/20auto-upgrades</code></em></p>

<p>This approach works on Linux(Ubuntu), especially deployed in production, but not Windows nor macOS. The last issue, is to be able to report problems when an update fails, so that a human can intervene whenever possible. That is where the second tool <code>apticron</code> in first paragraph intervenes. To make it work, we will specify which email to send messages to, and that will be all.</p>

<pre><code class="language-shell">EMAIL=&#34;&lt;email&gt;@&lt;host.tld&gt;&#34;
</code></pre>

<p><em><em>Example</em>: tuning reporting tasks email parameter <code>/etc/apticron/apticron.conf</code></em></p>

<h2 id="conclusion" id="conclusion">Conclusion</h2>

<p>In this article we revisited ways to install <code>nodejs</code> on various platforms. Even though <strong><em><a href="https://getsimple.works/how-to-configure-nodejs-applications#configure-redis-to-run-with-a-nodejs-server">configuration was beyond the scope of this article</a></em></strong>, we managed to get everyday quick refreshers out.</p>

<h2 id="reading-list" id="reading-list">Reading list</h2>
<ul><li><a href="https://github.com/nodesource/distributions#manual-installation">Manual Installation ~ NodeSource</a></li>
<li><a href="https://github.com/nodesource/distributions">Distributions ~ NodeSource</a></li>
<li><a href="https://getsimple.works/how-to-configure-nodejs-applications">Configuring <code>nodejs</code> applications</a></li></ul>

<p><a href="https://getsimple.works/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://getsimple.works/tag:homebrew" class="hashtag"><span>#</span><span class="p-category">homebrew</span></a> <a href="https://getsimple.works/tag:UnattendedUpgrades" class="hashtag"><span>#</span><span class="p-category">UnattendedUpgrades</span></a> <a href="https://getsimple.works/tag:nvm" class="hashtag"><span>#</span><span class="p-category">nvm</span></a> <a href="https://getsimple.works/tag:n" class="hashtag"><span>#</span><span class="p-category">n</span></a> <a href="https://getsimple.works/tag:y2020" class="hashtag"><span>#</span><span class="p-category">y2020</span></a> <a href="https://getsimple.works/tag:Jan2020" class="hashtag"><span>#</span><span class="p-category">Jan2020</span></a> <a href="https://getsimple.works/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://getsimple.works/tag:ConfiguringNodejsApplications" class="hashtag"><span>#</span><span class="p-category">ConfiguringNodejsApplications</span></a> <a href="https://getsimple.works/tag:tdd" class="hashtag"><span>#</span><span class="p-category">tdd</span></a> <a href="https://getsimple.works/tag:TestingNodejsApplications" class="hashtag"><span>#</span><span class="p-category">TestingNodejsApplications</span></a></p>
]]></content:encoded>
      <guid>https://getsimple.works/how-to-install-nodejs</guid>
      <pubDate>Fri, 31 Jan 2020 22:03:49 +0000</pubDate>
    </item>
  </channel>
</rss>