Every now and then, it’s helpful to get a bit of info from Recap. In this case, I’m looking at load average on a server. The one liner below prints out the load averages & times from the resource logs:

1
awk 'BEGIN {printf("\t%s \t\t%s %s %s\n" ,"TIME", "1min avg", "5min avg", "15min avg")} FNR == 1 {printf "%s",$1} FNR == 3 {printf("\t%6.2f %8.2f %8.2f\n", $10, $11, $12)}' resources*.log

And it yields output like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
TIME 		         1min avg 5min avg 15min avg
2015-01-08_00:00:01	  2.31     1.51     1.40
2015-01-08_00:30:01	  1.94     1.60     1.44
2015-01-08_01:00:01	  1.35     1.33     1.40
2015-01-08_01:30:01	  1.37     1.35     1.36
2015-01-08_02:00:01	  1.87     1.59     1.52
2015-01-08_02:30:01	  0.86     1.28     1.90
2015-01-08_03:00:01	  1.40     1.37     1.47
2015-01-08_03:30:01	  1.29     1.44     1.51
2015-01-08_04:00:01	  1.19     1.30     1.31
2015-01-08_04:30:01	  1.26     1.28     1.32
2015-01-08_05:00:01	  1.52     1.38     1.34
2015-01-08_05:30:01	  1.16     1.38     1.44
2015-01-08_06:00:01	  1.59     1.44     1.48
2015-01-08_06:30:01	  2.87     2.41     1.86
2015-01-08_07:00:01	  1.51     1.53     1.82
2015-01-08_07:30:01	  1.49     1.40     1.54
2015-01-08_08:00:01	  1.37     1.54     1.56
2015-01-08_08:30:01	  1.84     2.06     1.93
2015-01-08_09:00:01	  1.37     1.51     1.64
2015-01-08_09:30:02	  0.00     4.85     4.48
2015-01-08_10:00:01	  0.00     4.21     4.14
2015-01-08_10:30:02	  6.92     7.08     6.67
2015-01-08_11:00:05	  6.99     6.79     7.30
2015-01-08_11:30:03	  8.32     8.23     7.90
2015-01-08_12:00:02	  9.07     8.35     8.27
2015-01-08_12:30:04	  7.28     8.02     8.34
2015-01-08_13:00:02	  8.17     8.04     8.52
2015-01-08_13:30:07	 10.51     9.71     9.14
2015-01-08_14:00:08	 11.63    11.08    10.66
2015-01-08_14:30:05	 11.80    11.46    11.28
2015-01-08_15:00:04	  5.53     6.67     9.36

Feel free to use/reuse/abuse.

Cheers,

Aaron

I love Evernote–I really do. I’ve used it for note taking and as an idea scratchpad for several years now. I just want to have a bit more control over my data & notes.

I’ve looked over several self-hosted note taking apps, but haven’t really been happy with any of them. I’ve tried OpenNote and Laverna, but haven’t been really all that happy with the results. There were security issues with allowing any user to register–not something that I really want as a feature.

I finally came across Magpie. Magpie

It’s a python app that uses git repos to store the note info, rather than Laverna, or OpenNote, which are database backed. I’ll just say this–I love the app! It’s a sleek app that’s just fantastic. Like Ghost, it’s an app that uses Markdown, so it fits right in with my new workflow.

To install it, you’ll need a few things:

  • Python 2.7
  • Pip/Easy Install
  • Git

You might find that you also need the python-devel package to get magpie installed. Once you’ve installed the required packages, just run:

1
pip install magpie

You may need to run this with sudo, but you should be able to install it without issue. Once you’ve installed magpie, The next thing to do is to set up a git repo for your notes:

1
2
3
mkdir -p /path/to/notes/repo/
cd /path/to/notes/repo/
git init

Now, it’s time to start magpie. Start it with:

1
magpie

Or sudo, if you installed it with sudo. Now navigate to: http://127.0.0.1:8080/config to start setting things up. Optionally, you can set up Nginx to proxy to magpie using the same method in this previous post. Personally, I would opt for this. While you can change the option in the configs, if you’re going to host anything else on your server (e.g., multiple Ghost sites, or any site for that matter), you’ll want to set up the proxy.

If for some reason, you’re not able to get to the config via the web interace, you can always edit it at the following path:

1
  vim /usr/lib/python2.6/site-packages/magpie/config/web.cfg

This has the following:

1
2
3
4
5
6
7
username=''
pwdhash=''
testing=False
autosave=True
repo=''
address='localhost'
port=8080

You can edit these to your liking, and should keep a copy on hand should you ever need to migrate.

So there you have it! Give it a shot, and see what you think. Also, be sure and give Laverna, or OpenNote a shot too–they’re not my faves, but they’re by no means applications that you shouldn’t use. It’s just a matter of preference.

Ceers,

Aaron

This post is going to be an expansion on my previous post regarding moving from Wordpress to Ghost.io, and it’s going to cover a basic Nginx setup for your site. If you’d like something a bit more advanced, and want to get into doing caching, check out Pedro Teixeira’s post on tuning Nginx for Ghost.

You should already have your config files in place for Ghost. If you don’t, do not pass go, do not collect $200, go back and read the previous post.

Unlike Pedro’s Nginx config that is a bit expansive, or an Nginx config built out for Wordpress & php-fpm, this config is going to be dead simple. In fact, you can take what’s below, and copy/paste/tweak to your needs. Ready? Here we go:

1
2
3
4
5
6
7
server {
    server_name mysite.com;

    location / {
        proxy_pass http://127.0.0.1:2638;
    }
}

Yep, that’s it. Just that little bit. You could even do multiple server blocks here for each site if you really wanted to. And you know the best part? You can still be running a Wordpress site beside whatever sites you have running Ghost.

Let’s not forget to test out the setup. Restart Nginx:

1
service nginx restart

And head on over to your shiny new Ghost blog. Woot!

If you’ve just started tuning in, I’ve decided to make a switch from a self-hosted Wordpress deployment to a self-hosted Ghost deployment–and so far, I’m loving it. I’m switching for a number of reasons:

  • Security–Wordpress and it’s plugins have a long history of vulnerabilities.
  • Ease of use–I just don’t need something that has every bell and whistle
  • Resource use–Wordpress is a hungry devil, and the more plugins you add, the slower the beast tends to move
  • Simplicity–I’ve just found that Ghost is a clean, blogging-only platform that does what I need it to do…and it doesn’t hurt that it looks great too

That said, I wanted to give you a tutorial to get you started on making the switch, if that’s something you’re game for doing. If you’re technical, this should not be that difficult to set up. Let’s get started.

######Part 1: Getting your stuff from Wordpress This is a fairly simple process. Either from your admin page, or from the web, download and install the Ghost plugin. From there, go to Tools–>Export to Ghost, and run the export. You should get a .json file that you’ll download. The thing that’s not the greatest, is that you’ll have to deal with getting images back into your posts. If you don’t have a whole lot of posts, no big deal. But be warned, if you’ve got a photo heavy site, you’re gonna have a bad time.

######Part 2: Installing & Running Ghost This is where things are going to be a bit more technical, so if you’re not technical, or don’t know how to SSH/SCP something, this would be where I grab your cousin, brother, or any technical family member and have them run this bit.

  1. First, you’re going to have to download the file: wget https://ghost.org/zip/ghost-0.5.7.zip
  2. Extract the file: unzip ghost-0.5.7.zip -d your_directory_of_choice
  3. Copy the files wherever you need them for your site–whether they’re in /var/www or /home/Documents cp -R your\_directory\_of_choice /var/www/myghostsite
  4. Edit your configs. Here’s a snippet of how I have my production stanza set:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
     ```
     // # Ghost Configuration
     // Setup your Ghost install for various environments
     // Documentation can be found at http://support.ghost.org/config/
    
     var path = require('path'),
         config;
    
     config = {
         // ### Production
         // When running Ghost in the wild, use the production environment
         // Configure your URL and mail settings here
         production: {
             url: 'http://aaronmsachs.com',
             mail: {
                 transport: 'SMTP',
                     options: {
                         service: 'Mailgun',
                         auth:{
                           user: 'mailgunuser', // mailgun username
                           pass: 'mypass'  // mailgun password
                             }
                     }
             },
             database: {
                 client: 'mysql',
                 connection: {
                     host    : 'rackspace_cloud_db',
                     user    : 'myuser',
                     password : 'mypass',
                     database : 'mydb',
                     charset : 'utf8',
                 },
                 debug: false
             },
     ```
    

As a tip, I’d head over to mailgun configuration tool and follow that, if you’re interested in using mailgun to send mail for your site.

  1. Inside your ghost directory, run npm install --production
  2. Start up ghost–this is pretty easy, and you should get output on your screen that’ll indicate that things are running as expected: sudo npm start --production

######Part 2b (optional, but highly recommended): Configure Ghost to Be Persistent Through Reboots This bit’s something that one of my colleagues was wishing for when I was showing Ghost to him earlier in the day. By default, Ghost doesn’t appear to have an init script set up for it. For that, head on over to my post on creating an init script to ensure a quick start|stop|restart & allow the site(s) to be chkconfig’d on for persistence.

######Part 3: Importing Wordpress Content Into Ghost This is the part that contains the only beef I have with Ghost (photos not getting pulled in)–and it’s not even really Ghost’s issue–more like an issue with the plugin I used to generate the .json file.

  1. Navigate to your admin page-->settings-->labs ![](/content/images/2015/01/Settings_-_Labs_-_Aaron_Sachs-1.png)
  2. Import your export file.
  3. Magic--you should have all your content present now. </ol> Now head on over to your main URL, and everything _should_ be good to go. If you find yourself in a bit of a pickle, I'm more than happy to help. Just hit me up in the comments.

Hi there folks,

This is just a quick post on how to write an init script for Ghost on CentOS 6. This is adapted from Aron Duby’s post. First, install the forever package:

1
sudo npm install -g forever

Then drop the following script in /etc/init.d:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# Note runlevel 2345, 86 is the Start order and 85 is the Stop order
#
# chkconfig: 2345 86 85
# description: Start/Stop/Restart Ghost
#
# Below is the source function library, leave it be
. /etc/init.d/functions
 
# result of whereis forever or whereis node
export PATH=$PATH:/usr/local/bin
# result of whereis node_modules
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
 
 
start(){
        NODE_ENV=production forever start /path/to/your/ghost/index.js
}
 
stop(){
        NODE_ENV=production forever stop /path/to/your/ghost/index.js
}
 
restart(){
        NODE_ENV=production forever restart /path/to/your/ghost/index.js
}
 
case "$1" in
        start)
                echo "Start service SERVICE_NAME"
                start
                ;;
        stop)
                echo "Stop service SERVICE_NAME"
                stop
                ;;
        restart)
                echo "Restart service SERVICE_NAME"
                restart
                ;;
        *)
                echo "Usage: $0 {start|stop|restart}"
                exit 1
                ;;
esac

Run the script to test and ensure that the service starts/stops/restarts.

1
service ghost.website start|stop|restart

Also ensure that you chkconfig the new service on for persistence

1
chkconfig ghost.website on

And there you have it!

Cheers,

Aaron