As is obvious to the most casual of observers, I've never been the most prolific blogger. But, I have recently realized that I need to learn javascript (I can't stay a WPF
developer my whole career if MS decides to stop updating it...). At least if I want to have a future in software development. As a means to that end, I have decided to startup the blog again, and this time I have decided to use Ghost.
It is my intention to learn node.js
, and along the way, I can hopefully contribute some thoughtful words. If not, at least I will learn some much needed new skills.
So, I setup the blog on Azure, which was brain dead simple, but I ran into a few snags that took me way too long to figure out. So, I'll just drop them here in case anybody has the same issues and the googles don't seem to be helping.
First, when deploying the website with git, if you find your blog posts disappearing whenever you do a redeploy, it is because ghost uses sqlite
by default. The implications of this are that the database is stored in the filesystem. On your website. Which gets overwritten when you push new source to your azure repository. You can work around this by either deploying via FTP, and only copying over the files that have changed. Or, using FTP, you can pull down the ghost.db
file, and check it into your git repo.
Now, because I didn't want to go through that hassle every time I wrote a new post, I decided that maybe sqlite
wasn't the best choice for me. Since ghost supports MySQL and PostgreSQL, I figured I could set up a MySQL database on cleardb easily enough. There are many guides on the internet on how to get MySQL working with ghost.
So, I set it up, and as soon as I tried to set my theme to something other than casper... I got an error because there were too many connections open. You see, the free cleardb
plan only allows 4 simultaneous connections. And the mysql
driver defaults to allowing 10 simultaneous connections. Since it appears that ghost creates a lot of connections to the database in its normal operations, this is a problem.
After much searching of the intertubes, I discovered that you can specify the size of the connection pool used by knex (one of the libraries used to abstract the database storage). You can do so by setting up the maximum pool size in config.js:
database: {
client: 'mysql',
connection: {
host: 'path-to-cleardb',
user: 'user',
password: 'pw',
database: 'db-name',
charset: 'utf8'
},
pool: {
max: 4,
min: 0
}
}
I thought I was all set, but when I clicked the button to save a draft of the post... I learn I don't have permission to do so. It turns out that when ghost creates the permission tables, it assumes that the id columns will increment by 1. This seems like a normally safe assumption, but in the case of cleardb, they increment by 10 (I assume to allow up to 10 simultaneous inserts to work?).
This was easily fixed by altering the permissions_roles
table. Changing the values in permission_id
from
| id | role_id | permission_id |
+----+---------+---------------+
| 1 | 1 | 1 |
+----+---------+---------------+
| 11 | 1 | 2 |
+----+---------+---------------+
| 21 | 1 | 3 |
+----+---------+---------------+
to
| id | role_id | permission_id |
+----+---------+---------------+
| 1 | 1 | 1 |
+----+---------+---------------+
| 11 | 1 | 11 |
+----+---------+---------------+
| 21 | 1 | 21 |
+----+---------+---------------+
With that setup, I now have a fully operational battlestation blog.
-AH