Skip to main content

Posts

Communicate Through RabbitMQ Using NodeJS and Fastify

If we have two or more services that need to talk to each other but it is allowed to be asynchronous, we can implement a queue system in our system using RabbitMQ. RabbitMQ server will maintain all queues and connections to all services connected to it. This post will utilize Fastify as a NodeJS framework to build our program. This framework is similar to Express but implements some unique features like a plugin concept and an improved request-respond handler. First, we need to create two plugins, one is for sending a message, another one is for consuming the sent message. At first, we will make it using a normal queue. There is one mechanism for how a queue works, it is like a queue in the real world. When there are five persons in a queue and three staff to handle the queue, one person is served only by one staff, there is no need for other staff to handle any person that has been served, and there is no need for a person to be handled repeatedly by other staffs. For example

Is Data Important

Today, many systems may generate huge amounts of data such as system logs, financial transactions, customer profiles, security incidents, and so on. It is encouraged by the advancement of some technologies like IoT, mobile devices, and cloud computing. There are also fields that specifically learn to manage and process a lot of data like data science and machine learning. A set of data can be processed to produce certain results like detecting anomalies, predicting the future, or describing the state of a system. To generate such a result, the typical phases are collecting data, data preparation, visualization, and data analysis or generating results. In collecting data, we have to take some considerations including the location where the data will be stored, the type of stored data, and the retrieval method or how other systems can consume the data. When we want to select a location, we should consider whether the storage is available in the cloud or on-premise infrastructure,

Manually Select Private Key for Git CLI

We may utilize different keys for different projects or accounts. When we pull data from a Git repository through an SSH connection, by default the Git tool will follow the default SSH configuration for selecting the key used which is located in ~/.ssh/id_rsa . We can also set a custom SSH configuration located in the  ~/.ssh/config  file that will be followed by the Git tool too as explained in my other post . For setting the private key locally or per session, there are other options. First, we can utilize an environment variable that will be read by the Git tool for selecting the correct SSH command which is GIT_SSH_COMMAND . The usage is as follows. GIT_SSH_COMMAND="ssh -i ~/.ssh/your_id_rsa -F /dev/null" git clone git@github.com:your/project.git The -F /dev/null parameter is used for ignoring any available SSH configuration in the host. This method will apply the custom SSH command during the user session or it can be permanent too by setting it in the host envi

Managing Password in Unix Using Pass

If you are looking for simple password management in Unix, pass maybe the answer. It utilizes GPG to encrypt the stored passwords. It stores the encrypted passwords as text files in a tree of directories. Each directory can maintain a separate GPG key for encrypting the passwords stored inside it. How easy is it? The following command shows how we can store a password and set AWS/access-key-id as the variable name to access it in the future. pass insert AWS/access-key-id The previous command will automatically create a directory named AWS inside the  ~/.password-store  directory which is the default location of pass storage. It also creates a file named access-key-id.gpg inside the ~/.password-store/AWS directory. To access the value we can call the following command. pass AWS/access-key-id There are some steps we need to run for utilizing the tool. Install pass using package manager Create a GPG key pair record Initialize the pass storage with the spe

The First Time Kenshin Met Hiko

"Tell me your name" "Shinta" "Too soft for a swordsman, as of today you are Kenshin"

Essentials Ansible Modules

Ansible is a reliable configuration management tool. It is shipped with a lot of modules including those provided by the communities. Some modules are essential and come in very handy in everyday tasks. Ansible is pushed-based and works by generating a Python script that will be run on the target server. It means the target server is required to have Python which is also commonly shipped in any Linux distros. package The module is used to manage packages in the target host. It is like running apt , yum , or aptitude . The following snippet is an example of its usage to install the Nginx package using the package manager. tasks: - name: Install Nginx package: name: nginx state: present update_cache: True file It is used to manage files, symlinks, links, or folders on the target host. These are the two examples. tasks: - name: Create a directory file: path: "/home/luki/mydir" state: directory mode: 0750 - name: C

Installing VSCode Server Manually on Ubuntu

I've ever gotten stuck on updating the VSCode server on my remote server because of an unstable connection between my remote server and visualstudio.com that host the updated server source codes. The download and update process failed over and over so I couldn't remotely access my remote files through VSCode. The solution is by downloading the server source codes through a host with a stable connection which in my case I downloaded from a cloud VPS server. Then I transfer the downloaded source codes as a compressed file to my remote server through SCP. Once the file had been on my remote sever, I extracted them and align the configuration. The more detailed steps are as follows. First, we should get the commit ID of our current VSCode application by clicking on the About option on the Help menu. The commit ID is a hexadecimal number like  92da9481c0904c6adfe372c12da3b7748d74bdcb . Then we can download the compressed server source codes as a single file from the host.

Creating Self-signed and CA Certificate using OpenSSL

A self-signed certificate is very useful for us when we are in a development or closed environment and require a secure communication channel between nodes in our system like implementing HTTPS for client-server communication. To make our self-signed certificate to be recognized by all nodes in the system, we should generate the CA certificate and distribute it to all nodes. This CA certificate is used to verify and determine the issuer of the self-signed certificate. It is like a stamp on a certificate that ensures the certificate is issued by the authority informed in the certificate itself. OpenSSL CLI tool will be used for this purpose. The following steps can be run to generate valid self-signed and CA certificates. Generate a private CA key Generate a public CA certificate Generate a private key for the target server Generate a CSR for the server Generate a public server certificate and sign it with the CA certificate Before we start the certificate generatio

Managing Kubernetes Cluster in Ubuntu

There are several tools and services in the market that we can use to deploy and manage Kubernetes clusters. Some tools allow us to self-manage the cluster without charge, some require us to subscribe for the license, and some services are provided as a Kubernetes as a Service such as Amazon EKS and Red Hat OpenShift Dedicated. For development purposes or small-scale service, there is a free tool to manage Kubernetes clusters named minikube which is available for Windows, Linux, and MacOS. To build the cluster, Minikube supports several virtualization technologies such as Hypervisor, KVM, Docker, and so on. In this writing, we will try to utilize Docker as the virtualization solution and run it in Ubuntu 22.04. In general, we will run through the following steps. Install Minikube Install Docker Allow a non-root user to access Docker Start Minikube Enable Ingress extension Install Kubectl Install Minikube First, we need to install Minikube's depen

Detecting Main Module in ESM Package

ESM package works in a different fashion from CJS. ESM package imports required modules asynchronously and have no support for several functions related to system files and directories. ESM follows Javascript cores that are implemented in the browser. There is no such entity like __dirname , __filename , require() , and so on. If we want to detect whether a module is a main module that is being run in CJS, we can compare the value of require.module and module . If it is the same, the module is being run as the main module. Meanwhile, for a module in the ESM package, we can use the following approach. Get the value of process.argv[1] that contains information of the main file that is being called by Node. Get the value of import.meta.url that contains information of the module's location that is being accessed. Transform the information to have a similar format, then compare it. For example, we have a module in an ESM package, named module1.js . import { r

Captain Levi Talked To Armin

At this point, Armin and the others start questioning their actions while Levi tries to justify what was happening.

Upgrading Gitlab Using Linux Package

Gitlab actively updates its products including the Community Edition (CE). The easiest way to install Gitlab CE on a Linux machine is by using the package manager. To add the repository to our system, we can run the following command. sudo apt update curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash Before we run the upgrade process, we should follow the recommendation of the version order. If not, we may end up breaking our Gitlab service. Upgrading one version to another version far greater may require upgrading from previous versions first, step by step. To check our current Gitlab version, we can visit <OUR_GITLAB_ADDRESS>/help . The upgrade recommendation can be found  HERE . Note, we are also suggested to upgrade our Gitlab regularly for security reasons. We can get the list of available versions HERE . To apply the upgrade on our machine, we can run the following command. sudo apt-get install gitlab-ce=<VERSION_C