0%

Just a quick troubleshooting post for anyone using Hexo at the moment. If you go into your Hexo directory and do any Hexo command but recieve something similar to this:

1
2
3
[Error: Module did not self-register.]
{ [Error: Cannot find module './build/default/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/Debug/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }

Don't worry - it's a really quick fix. Courtesy of Tommy351

Simply type:

1
npm install hexo --no-optional

That will get your Hex instakl back up & running no probs.

If you're curious and want to know more checkout this issue on Github

# What I'm Currently Listening To

As a relatively new user to Hexo I thought it only right to put my contrbution into the mix with a new plugin. I was inspired by Ivanov Yordan's Spotify tag plugin here.

The Deezer Tag Plugin.

It enables you to use a tag like this:

1
{% deezer trackid %}

To get something like this in your blog posts:

Or maybe you want it square?

I'm planning to add support for the Deezer HTML5 widget at a later date. The current version uses the iframe plugin and if you're interested in what the full widgets are cacapble of without using short tag plugins like this then checkout the Deezer widget page.

However, the advantages with this:

  • Integration with Hexo.
  • Easy to put a track in your post.
  • Less HTML cruft to deal with. Just a nice tidy tag.

Checkout the Github repo for info on installation and usage.

Monit is a comparitively lightweight server monitor. I'd say its biggest sellig point is th ease ans sped of setup compared to the more enterprise-grade monnitoring services like Nagios, Icinga, Munnin, Zabbix, etc. Those are likely overkill unless in an enterprise situation.

Although I say comparitively lightweight you'll find as you dig into Monit it has a great depth of features. I came to use it recently because a problem I've recently run into with PHP-FPM dying for no apparent reason leaving me with a bad gateway timeout for nginx.

Monit to the rescue which will detect the dead service, restart it, log it and continue monitoring.

# Install

This assumes you're running Ubuntu/Debian in all the following but you should be able to adapt it for your own distro.

1
2
sudo apt-get update
sudo apt-get install monit

After Monit is installed go ahead and use your fave editor (Vim obviously) and edit monits config file:

# Basic Setup

1
sudo vim /etc/monit/monitrc

There's a few key things you'll want to change in here and a few that are optional but the config file is great with loads of explanation on each variabe you can change.

/etc/monit/monitrc
1
2
3
4
5
6
7
8
9
10

# Checks pocesses every 2 minutes (120 secs) for up state
set daemon 120

# Use the localhost as the mailserver for sending alerts (change as appropriate)
set mailserver localhost

# The email address to send alerts of services being dwn and restarted
set alert your@email.com

# Service Monitoring

Service monitoring is just one of the many core facets of Monit but its the one I'm focussing on in this blog. Even within basic service monitoring there's a lot extra options you can use but I'm keeping it simple for now. If you want to go into more detail such as file checking, space, network monitoring, etc check out the full manual at monit HQ.

Heres a very basic example for checking 3 services on yoru box:

/etc/monit/monitrc
1
2
3
4
5
6
7
8
9
10
11
12
13

###############################################################################
## Services
###############################################################################
check process php5-fpm with pidfile /var/run/php5-fpm.pid
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"

Afer doing any changes to the monitrc file you must run:

1
sudo monit reload

# Web Interface

If receiving notifications and allowing Mnit to do its thing isn't enough then you can satisfy your inner voyeur by setting up the Monit httpd service. In the monitc file find the commented out section below:

/etc/monit/monitrc
1
2
3
4
5
6
7
8

# set httpd port 2812 and
# use address localhost # only accept connection from localhost
# allow localhost # allow localhost to connect to the server and
# allow admin:monit # require user 'admin' with password 'monit'
# allow @monit # allow users of group 'monit' to connect (rw)
# allow @users readonly # allow users of group 'users' to connect readonly

The comments make it pretty self explanatory but to give you an idea I've included a simple example here:

/etc/monit/monitrc
1
2
3
4
5
6
set httpd port 2500 and         # The port to allow access from
use address 101.102.103.104 # Your servers IP address to bind to
allow 89.90.91.92 # Your IP address
allow username:password
allow @monit
allow @users readonly

With those settings you can visit http://101.102.103.104:2500 and after putting in the username and password above you will be presented with something like this:

# Going Further

This really only scractes the surface of what Monit can do as you may have noticed with the huge number of examples and sub-rules to checks in the monitrc file. I'd strongly recommend reading through the config file and checking out the manual too for some of Monits more powerful features.

# Troubleshooting

# Problem 1 - Missing PID files

If you find your MySQL server doesn't have a pid file (one of my servers didn't) then its as simple as adding it to your config file (in MySQL's case: /etc/mysql/my.cnf) like so:

1
pid-file    = /var/run/mysqld/mysqld.pid

Then set the location of that pid file in your server monitoring configs as above.

# Problem 2 - Alert emails not working

This is pretty common especially if you're using the localhost. Its most likely they are going to spam or your server is simply picking them up due to a misconfigured Postfix install. Check your spam folder and try a different alert email on a different domain to narrow down the issue.

# Currently listening to...

If like me you have had annoying 404's pop up during apt-get update and no amount of fiddling with the /etc/apt/source.list then it means your Ubuntu has reached End of Life. AKA: it's an OAP.

It needs a bus pass.

So to help it out simply change all instances of archive.ubuntu.com and security.ubuntu.com to old-releases . Like so:

/etc/apt/source.list
1
2
3
4
5
6
7
8
9
10
11
12
13
# From this:
#deb http://archive.ubuntu.com/ubuntu quantal main
#deb http://archive.ubuntu.com/ubuntu quantal-updates main
#deb http://security.ubuntu.com/ubuntu quantal-security main
#deb http://archive.ubuntu.com/ubuntu quantal universe
#deb http://archive.ubuntu.com/ubuntu quantal-updates universe

# To this:
deb http://old-releases.ubuntu.com/ubuntu quantal main
deb http://old-releases.ubuntu.com/ubuntu quantal-updates main
deb http://old-releases.ubuntu.com/ubuntu quantal-security main
deb http://old-releases.ubuntu.com/ubuntu quantal universe
deb http://old-releases.ubuntu.com/ubuntu quantal-updates universe

Then run sudo apt-get update to get the 'fresh' list of packages you're used to But its highly recommended you upgrade your distro to a more up-to-date version by following the steps at Ubuntu's community EOL page.

I had the idea for this post after accidentally stumbling across KrakenJS and realising its a Paypal open source project.

OK so its pretty obvious companies like Google, RedHat, Oracle, etc all contribute to the open source community and even stand on its shoulders to a great extent. But after finding Paypal's contributions I did some digging to find some lesser known coroporate open source contributors. And some cool projects popped up.

There was a time when I'd do a lot of coding using Google API's and open source libraries but over the years I'd become dissillusioned with them and as a result subconciously steered clear of any future corporately sponsored projects.

# Quick KrakenJS intro before the main list

Not only is KrakenJS a much beefed up version of the Node framework ExpressJS with lads of extras including:

  • Application Security
  • NPM Proxy
  • Dust I18N
  • Dust Context

It's also a way to structure your project. It is like Sinatra's Padrino of the Ruby world.

# 1. Paypal

As I've already mentioned Paypal's greatest contribution (IMHO) KrakenJS here's Paypals GitHub page with all their projects:

# 2. Netflix

First it was a major banking organisation. Now we've the darling of media streaming services to the public and paraiah to US ISPs.

The Netflix open source contribution is no less impressive than PayPals - maybe even more so which is why its criminal its not more widely known. So here's a heads up on their:

Some of their notable projects:

  • Asgard - Web interface for application deployments and cloud management in Amazon Web Services (AWS)
  • Scumblr - cool custom search engine. Check the page for full info.
  • SimianArmy - Tools for keeping your cloud operating in top form.

# 3. Spotify

Some of their projects:

Check out the developer blog for all their API's and SDKs.

# 4. UK Government

What? That stuffy old wood and leather palace with its yays and nays? Yep - ineed they have such a prolific open source collection on Github (19 pages of repos!) It was hard to dig out the gems. Its worth checking them all and there's some that are criminally under-appreciated. Here's a few:

  • Magna Charter - Accessible, useful, beautiful barcharts from HTML tables.
  • Gov.UK Styleguides - Good to see the government have style guides in place.
  • Router - Just, erm. Wow. Check the readme - maybe you'll make more sense of it than me. Seems built on Go and handles routing for the main Gov.uk site.

One thing I have noticed is the UK Government does seem to like it's Ruby, esp. Ruby on Rails.

Check out the full 19 page monster list at AlphaGov.

# 5. The Guardian

The UK newspaper currently has a list of repos to rival the Government's but the potential for cool finds does seem a bit higher. Here's a few I managed to dig out:

Of course the Guardian wouldn't be much of a newspaper without its own developer blog now would it:

If you think I've missed off any great projects let me know: doug (at) tintophat (dot) com