<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aneesh Anil</title>
    <description>The latest articles on DEV Community by Aneesh Anil (@aneeshanil).</description>
    <link>https://dev.to/aneeshanil</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F749457%2Fbe246698-572f-4874-ad90-5fbaa49cc82b.jpeg</url>
      <title>DEV Community: Aneesh Anil</title>
      <link>https://dev.to/aneeshanil</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aneeshanil"/>
    <language>en</language>
    <item>
      <title>Hunting space gobblers in Ubuntu OS.</title>
      <dc:creator>Aneesh Anil</dc:creator>
      <pubDate>Mon, 27 Jun 2022 03:21:51 +0000</pubDate>
      <link>https://dev.to/aneeshanil/hunting-space-gobblers-in-ubuntu-os-15jk</link>
      <guid>https://dev.to/aneeshanil/hunting-space-gobblers-in-ubuntu-os-15jk</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;The other day one of my slack channels started buzzing. It said our DGraph database was down.This seems to happen sometimes, usually restarting works. But here it wasn't!&lt;br&gt;
2 seconds after a restart, it goes down again.&lt;/p&gt;
&lt;h3&gt;
  
  
  No Space
&lt;/h3&gt;

&lt;p&gt;One thing I noticed while I was logged into the droplet where Dgraph was hosted, was the OS wasn't able to autocomplete my commands on pressing &lt;code&gt;tab&lt;/code&gt; key. So there was no space.&lt;br&gt;
I was stumped, what was happening ?!? &lt;/p&gt;

&lt;p&gt;So I ran &lt;/p&gt;

&lt;p&gt;&lt;code&gt;df -h&lt;/code&gt; which showed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filesystem      Size  Used Avail Use% Mounted on
.
.
/dev/vda1        49G  45G   45G   100% /
.
.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whoa! What is &lt;code&gt;/dev/vda1&lt;/code&gt; and why is it's usage at 100% ?&lt;/p&gt;

&lt;h3&gt;
  
  
  The hunt
&lt;/h3&gt;

&lt;p&gt;So I used &lt;code&gt;du -h --max-depth=1&lt;/code&gt; from root &lt;code&gt;/&lt;/code&gt;, and I noticed &lt;code&gt;/var&lt;/code&gt; had a huge usage. &lt;br&gt;
Moved into &lt;code&gt;/var&lt;/code&gt; and ran the same, now &lt;code&gt;log&lt;/code&gt; had a huge usage. &lt;br&gt;
Turns out it was &lt;code&gt;syslog&lt;/code&gt; that was using up the space.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;Went ahead and truncated &lt;code&gt;syslog&lt;/code&gt; now, &lt;code&gt;/dev/vda1&lt;/code&gt; is at &lt;code&gt;9%&lt;/code&gt; usage.&lt;br&gt;
We also cleaned up &lt;code&gt;/tmp&lt;/code&gt;. &lt;br&gt;
And set the logs to rotate. &lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendation
&lt;/h3&gt;

&lt;p&gt;We didn't see a need to backup the &lt;code&gt;syslog&lt;/code&gt; but it's recommended that anybody clearing it up do backup for later analysis on why it fills up, if that happens regularly. &lt;br&gt;
In our case the server has been running for quite some time, some it was just a natural accumulation of logs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Another potentially useful command
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;du -sh [/path]&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;How to deleted &lt;code&gt;syslog&lt;/code&gt; safely. [&lt;a href="https://stackoverflow.com/questions/35638219/ubuntu-large-syslog-and-kern-log-files"&gt;https://stackoverflow.com/questions/35638219/ubuntu-large-syslog-and-kern-log-files&lt;/a&gt;]&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ubuntu</category>
      <category>devops</category>
    </item>
    <item>
      <title>Using Cloud Firestore Emulator for local development</title>
      <dc:creator>Aneesh Anil</dc:creator>
      <pubDate>Sun, 02 Jan 2022 13:55:52 +0000</pubDate>
      <link>https://dev.to/aneeshanil/using-cloud-firestore-emulator-for-local-development-3bbh</link>
      <guid>https://dev.to/aneeshanil/using-cloud-firestore-emulator-for-local-development-3bbh</guid>
      <description>&lt;p&gt;I want to build a small project, I would like to host it as well. So I did some digging and found out Google Cloud offers free tier upto a limit. This is awesome, all I need is a laptop and an internet connection and I can create a small startup from home!&lt;/p&gt;

&lt;p&gt;My basic concern is where to store data? Cloud Firestore is a NoSQL document database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;I have never worked with NoSQL databases, so I wanted to try it. The setup is pretty straightforward, go to &lt;a href="https://console.firebase.google.com"&gt;Cloud Console&lt;/a&gt; and Click &lt;code&gt;Add Project&lt;/code&gt; and follow the flow to setup a project. Once that is complete  navigate to the Cloud Firestore section of the Firebase console. You'll be prompted to select an existing Firebase project. Follow the database creation workflow. &lt;a href="https://firebase.google.com/docs/firestore/quickstart"&gt;Google has super docs on how to setup project and firestore&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we don't want to use this database for development, we would like to keep that for prod use only, that is where emulator comes in. &lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Emulator
&lt;/h2&gt;

&lt;p&gt;To install the emulator Firebase CLI needs to installed already. Check if it is installed by running the command &lt;code&gt;firebase --version&lt;/code&gt; if that showed a version you are good otherwise proceed to install it. For Linux/MacOS running the auto-install script (&lt;code&gt;curl -sL https://firebase.tools | bash&lt;/code&gt;) is the simplest way to do that. For more info and on how to install in Windows OS check out this &lt;a href="https://firebase.google.com/docs/cli"&gt;docs&lt;/a&gt;. &lt;br&gt;
Once the script completes successfully check if the installation is successful or not by using the command &lt;code&gt;firebase --version&lt;/code&gt;. Then navigate to your project and init firebase &lt;code&gt;firebase init&lt;/code&gt;. Then initialise emulators &lt;code&gt;firebase init emulators&lt;/code&gt; and select Firebase from options. &lt;/p&gt;

&lt;p&gt;To start the emulator locally use cmd &lt;code&gt;firebase emulators:start&lt;/code&gt; and in the browser open the Emulator UI. &lt;/p&gt;

&lt;p&gt;Now to connect to the Firestore emulator using Go, download the dependency &lt;code&gt;go get firebase.google.com/go&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// imports
...
"cloud.google.com/go/firestore"
firebase "firebase.google.com/go"
"google.golang.org/api/option"
...

// Use the application default credentials
ctx := context.Background()
conf := &amp;amp;firebase.Config{ProjectID: os.Getenv("GCP_PROJECT_ID")}
app, err := firebase.NewApp(ctx, conf)
if err != nil {
    log.Fatalln(err)
}

client, err := app.Firestore(ctx)
if err != nil {
    log.Fatalln(err)
}
return client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now use that client to talk to the database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_, _, err := client.Collection("users").Add(ctx, map[string]interface{}{
    "first":  "Alan",
    "middle": "Mathison",
    "last":   "Turing",
    "born":   1912,
})
if err != nil {
    log.Fatalf("Failed adding aturing: %v", err)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see this document in the Emulator UI. &lt;/p&gt;

&lt;h2&gt;
  
  
  Persisting the data
&lt;/h2&gt;

&lt;p&gt;When we exit the emulator we loose the data.&lt;br&gt;
To persist the data across multiple sessions use &lt;code&gt;firebase emulators:start --import &amp;lt;export-directory&amp;gt; --export-on-exit&lt;/code&gt; will import the data on startup and save the data on exit. &lt;/p&gt;

&lt;p&gt;A more detailed explanation can be found &lt;a href="https://mukhtharcm.com/firebase-emulator-persist-data/"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>cloud</category>
      <category>googlecloud</category>
      <category>go</category>
    </item>
  </channel>
</rss>
