RocketChat server not running. Cancelling

As you might know, I’ve set up a RocketChat server recently on Digital Ocean. So far it’s been working great. An update every once and a while is all it needs.

However, yesterday, I attempted an update that failed. From then on every attempted update resulted in “RocketChat server not running. Cancelling”. This was very frutrating.

First, a few commands to try that might help:

  1. systemctl restart rocketchat.service – This will start your RocketChat server in case it is stopped.
  2. systemctl status rocketchat.service – Use this command to check the results of the previous command. Typically this will report that the service is “Active” if the previous command was successful.

In my case, the second command resulted in a “failed” state. The command itself gave me some information as to what the failure was, but not a lot of context as to what caused the failure. However, it did show me the process that it attempted to run. It said, ExecStart=/opt/nvm/versions/node/v14.19.3/bin/node /opt/Rocket.Chat/main.js (code=exited, status=1/FAILURE).

Alright! We’re getting somewhere. With that I was able to figure out what command failed and where that command was run. I navigated directly to the /opt/Rocket.Chat directory which was where the failure was occurring. From here I ran node main.js. The results of this command were much more helpful. They told me this, Error: Cannot find module '@meteorjs/reify/lib/runtime'. That looks like an issue with npm dependencies.

So, I poked around the Rocket.Chat directory structure and looked for dependencies for the Rocket.Chat server. I found what I was looking for in the /opt/Rocket.Chat/programs/server directory.

From this directory I ran two commands

  1. npm install
  2. npm ci

Afterwards I attempted to start the RocketChat server again using the systemctl restart rocketchat.service command. I checked it with systemctl status rocketchat.service and found that it was working now! RocketChat was back to running normally. The problem with “RocketChat server not running. Cancelling” was gone!

Getting Started with Rocket Chat Using Digital Ocean Backing

RocketChat (https://rocket.chat) is a chatting tool similar to MatterMost and Slack. It offers a self-managed community edition as well as some paid plans and is in active development. I’m just learning how to use it, so I’m planning on documenting my journey here.

I installed and set up RocketChat installed in a matter of minutes. The QuickStart guide, though short, includes most of what you need to get up and running.

To get started with your RocketChat instance on DigitalOcean you need to:

  1. Create a DigitalOcean account
  2. Install RocketChat
  3. Create an A Record that points to your Digital Ocean Droplet. *
  4. Setup your Let’s Encrypt certificate.
    rocketchatctl configure --lets-encrypt --root-url=YOUR_DOMAIN --letsencrypt-email=YOUR_EMAIL
  5. Update your RocketChat installation. Run the following commands from your droplet command line interface.
    1. Run sudo rocketchatctl upgrade-rocketchatctl
    2. Run sudo rocketchatctl update

* I use Cloudflare to host my DNS. In this case I had to disable the proxying on the A Record in order to allow RocketChat to work correctly.

Now visit your site (you should not run into any problems) and create your administration account.

One Note

From time to time the Rocket Chat server responds with “Bad Gateway”. I’m not sure exactly why. However, a DigitalOcean droplet can be restarted by using the reboot command from the command line interface.

Git Commits for the Current Branch

I had need to get a list of a simple list of all commits for the Current branch. This approach was simple enough and gave me what I wanted. I modified it to just use HEAD so that I can easily run it against the current branch.

git shortlog --no-merges --graph --abbrev-commit master..HEAD

This came from Alex who posted it on StackOverflow here: https://stackoverflow.com/a/61284456/296889

Validate the Hash or Checksum of a Downloaded File

Every once and a while I want to validate the hash of a downloaded file. Most of the time these are MD5 hashes, but I’ve seen SHA as well.

Windows actually has a couple built in ways of generating the hash of a file. You can use certutil or, in powershell you can use get-filehash.

With Certutil

To verify a checksum with certutil use the following command: certutil -hashfile {FILENAME} {ALGORITHM} replace the FILENAME and ALGORITHM with your choices.

With get-filehash

This is my preferred method. No reason, maybe I like the order of arguments better?

Use get-filehash -algorithm {ALGORITHM} {FILENAME}.

That’s it!

Clean up Previously Merged Git Branches

First things first, I tend to build up a lot of local branches. No, I don’t pro-actively remove them from my machine. (Who does that extremely smart thing? 🙄) At work we use GitHub and Windows. As such I use posh-git to perform almost all my git interactions (you should too cause it’s 👌).

Our current process is:

  1. Create Feature Branch
  2. Create Pull Request
  3. Squash and Merge Pull Request
  4. Delete Feature Branch from Remote

Any developer can have any number of feature branches out at a time waiting to be merged.  As we are using a “Squash and Merge” process our branches are not *actually merged*. We delete the original branch after the squash.

But that doesn’t really matter to you. Come to think of it, it doesn’t really matter to future me. What does matter is, how can I remove local git branches that aren’t on the git remote anymore? (Remote meaning GitHub, Gitlab, Bitbucket, etc…). No, we aren’t talking about the remote tracking branches that are removed by pruning. Otherwise, one could just prune, no?

I continuously search for this, so I’m documenting it here so I NEVER HAVE TO SEARCH EVER AGAIN 😤

First of all, the answer to the question comes from this question on StackOverflow.

git checkout master; git remote update origin --prune; git branch -vv | Select-String -Pattern ": gone]" | % { $_.toString().Trim().Split(" ")[0]} | % {git branch -d $_}

If you are in a position where you Squash & Merge then you will need to replace the git branch -d with git branch -D. This will successfully remove all “:gone” branches from your local machine.

If you are using linux, and not powershell, you can use the following command taken from the same question on StackOverflow.

git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d

But Why?!

Any git branch you have checked out essentially has three branches.
1. The remote branch on GitHub
2. The remote tracking branch on your machine
3. The local branch you do your work on.

When we push a feature branch live (merge a pull request) we delete the “remote branch on GitHub” (#1 above).

When we run `git fetch origin –prune` we remove the remote tracking branch (taking care of #2) above.

However, taking care of #3 above often requires manual clean up. That’s where the piped command above comes into play, it takes care of cleaning up branch #3.

Include Surrounding Lines with Grep

I find it extremely useful to include surrounding lines when I’m searching through log files or whatnot for a string of text. It certainly helps provide some context as to what I’m looking at.

However, I constantly forget the flag for including surrounding lines. So I’m posting it here so that, at least when I forget, I know where to find it 😮

The flag is -C. I suppose it should be easy to remember since I want “Context” and “Context” begins with “C”. 🤔

Below is a quick example for just in case you want the whole command or you enjoy copying and pasting all the things – hey… no judgement here.

grep -C 5 "[5aa027aeb0ebb]" my_special_log.log

Ubuntu Server not completing upgrade

It’s been about seven months since I setup a Wireless GitLab server. Since then I’ve figured out how to list updatable packages on Ubuntu Server. I’ve also performed several updates using sudo apt-get update && sudo apt-get upgrade.

gzip: stdout: No space left on device

Today I ran into a new problem. Upon trying to perform an update I was presented with a peculiar error. It said gzip: stdout: No space left on device and it told me to run apt-get -f install to fix things up. So… that’s what I tried doing. I tried running the apt-get -f install command but to no avail. The command would not complete successfully.

This is about the time when I start getting really annoyed with Linux and the command line and all the things associated with configuring things manually like do I really need to download the entirety of the Linux MAN files inside my HEAD? DO I NEED TO DO THAT? GAHasldkjsadljfsadfsdsdf!!!!

Calm yourself.

The /boot partition is 100% full

Ok, so it turns out that the apt-get process can fail if the /boot partition becomes 100% full. There were a number of suggestions online that indicated you needed to clean out the /boot partition by removing old linux-images that you don’t need anymore. Many of these suggestions involved using sudo apt-get remove [package-name] or using sudo apt-get autoremove which are both completely valid options… IF APT-GET WERE WORKING. But apt-get is not working, that’s the problem.

So… I Googled a lot and dug through a lot of forums. Finally I stumbled on this uber helpful answer on askUbuntu. I’ll go ahead and paraphrase the answer below so that I can easily find it again. Yes. This is all about me.

Cleaning up the /boot partition

In the case where your /boot partition becomes totally full you can use these steps to clean it up. (From flickerfly on AskUbuntu).

  1. Run the following command to get a list of the linux-image files that you don’t need anymore.
    sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`
    
  2. Create a command to remove the folders you don’t need anymore. You can do that with a command like this (where brace-expansion is used to save keystrokes). Use the output from the command above to build your command.
    EXAMPLE
    sudo rm -rf /boot/*-3.2.0-{23,45,49,51,52,53,54,55}-*
    
  3. Now that apt-get has space to work with you can actually run sudo apt-get -f install to clean things up.
  4. Use Purge to manually resolve issues with “Internal Errors” (if you get any internal errors).
    EXAMPLE
    sudo apt-get purge linux-image-3.2.0-56-generic
    
  5. Run `sudo apt-get autoremove ` to clean up anything orphaned by the manual clean.
  6. Now you can finally proceed with those updates you were wanting to do.
    sudo apt-get update && sudo apt-get upgrade
    

Party?

We can party now I think.

Secrets were required, but not provided

Psst… tl:dr -> rebooting my wireless router fixed the problem.

A few months ago I setup a wireless Gitlab server. This server has been working great. Once in a while I check up on it via SSH and make sure it’s updated. Otherwise, I leave it alone and it’s happy.

That is until today.

Secrets were required, but not provided

Today, for some reason, I could not access my gitlab server via the web interface or push to it via the git cli. In fact, I couldn’t even SSH into it. I had to pull out the ol’ physical monitor and keyboard and MANUALLY connect. Shudder.

First thing I do upon connecting to the server is try to ping google.com of course. It didn’t work. The server could not find the address for Google, and as anyone knows, if you cannot find Google then the internet does not exist. Plain and simple. You might as well be trying to fly a kite in the Marianas trench.

Now, up until this point I’ve had no issues connecting to the internet. The server automatically connects to the WIFI no big deal. However, I thought that maybe the network authorization expired or something? Maybe I can only connect for a few months at a time before re-authenticating. So I tried just that. I whipped out my old friend nmcli and ran:

nmcli device wifi connect MyAccessPoint password 123456789ACB

This is when I see the dreaded Secrets were required, but not provided response. Well – I’m not sure what secrets it wants me to tell it but I mean, the password was right, and I’m certainly not telling it who my favorite little pony is or even if I like little ponies.

I tried several more times, I tried rebooting the server. Nothing worked. It was at that point that I, using another computer, logged into my wireless router and told it to reboot. Several minutes later everything is fine.

Rebooting my router fixed the problem

Why? I don’t know. There has been some talk that some routers will auto select channels that some linux machines do not like. I think that was likely the original issue. Rebooting the router worked because another channel was selected. In any case… long story short. If you are having issues with your wireless server not connecting to your network then try rebooting your router.

List Updatable/Upgradable Packages in Ubuntu Server

A little while ago I setup a GitLab box using Ubuntu Server. When I log in to the server it shows me a short message about available updates. The message looks something like this:

Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-24-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

7 packages can be updated.
0 updates are security updates.

I know that I can update these packages by running `sudo apt-get update && sudo apt-get upgrade` however, I’d like to know what I’m updating before I do it. In the past you could accomplish this by performing a “dry-run” of the command. This essentially showed you the output of the command without actually performing any updates. That worked alright – but honestly, I just want a list of the packages – not the entire output of the command.

Listing the Upgradable Packages

I stumbled upon this answer (made just a few days ago) by AskUbuntu user “doru“. Turns out that getting a list of updatable/upgradable packages is pretty easy. You just run this:

sudo apt list --upgradable

The list --upgradable command will list out all the packages that you can update, what their current versions are, and what the new version is. Boom! That’s exactly what I wanted.

GIT CLI SSH PassPhrase

I use the GIT command line interface a lot. It helps me keep my Git repositories looking sharp and clean. Interactive rebase auto-squashing with posh-git+ConEmu ftw!

However, from time to time I will notice that the GIT cli is asking me for my SSH RSA passphrase more often than I’d like. Sometimes it even asks on every pull. That’s annoying.

It is possible, however, to only enter your passphrase once per session. Setting this up should be as simple as doing the following:

  1. Add the “bin/” folder of your GIT install to your $PATH. This will allow you to reference ssh-agent in your powershell environment.
  2. From your Powershell environment run
    ssh-agent
  3. Now run
    ssh-add

Excellent! That should be it. Now you should be able to push, pull all you want without having to insert your passphrase more than once per session.