2018-03-17
Adding Commento to Celestial Toys

I have been wanting to add an in-blog feedback mechanism (i.e., comments) for years, but never got around to it. During my recent Spring Cleaning My Blog, I had the chance to try out Disqus, but soon rejected it as bloaty and not very portable. Most importantly, it doesn’t support Markdown.

So I looked at some other alternatives and filtered them down to Schnack and Commento. Both support Markdown, and both require that they be installed and hosted on some cloud server, under my control. I treat this requirement as a feature, although both products will likely encourage SaaS versions for users not wanting to run their own server.

Installing on Ubuntu on AWS

Creating a commento user

I created a user with an unmemorable password, and I use:

sudo su - commento

to become the commento user.

Installing Commento

As user commento, clone the Commento GitHub repo into your home directory, as described in Commento in GitHub.

cd /home/commento
git clone https://github.com/adtac/commento.git

Build commento, as per the instructions in the Commento README.

Creating a commentoStartup file

Because the way that the commento binary discovers its .env files seems to be incompatible with being launched as a systemd unit, I created a little script that will be invoked by systemd and then will invoke commento the way that it expects, so that it can read the COMMENTO_PORT and COMMENTO_DATABASE_FILE variables. I’m sure that I’ll eventually figure out the proper Go way to use these tools, but right now, this works. Here’s what my commentoStartup looks like:

echo "Starting Commento..."
cd /home/commento
./commento/commento

Setting up a systemd unit

I’m using Ubuntu 17.10, currently. These instructions worked for me

cd /lib/systemd/system
sudo vi commento.service

Edit the commento.service file above (using your favorite editor; mine is vim) to contain the following contents:

[Unit]
Description=Commento server
After=network.target

[Service]
User=commento
#EnvironmentFile=/home/commento/.commento_env
Restart=always
RestartSec=5
ExecStart=/bin/bash /home/commento/commentoStartup

[Install]
WantedBy=multi-user.target

Configuring your commento service to start at boot

sudo systemctl enable commento


Comments