#!/usr/bin/env node

'use strict';

var Promise = require('bluebird'),
    mongoose = require('mongoose'),
    config = require('../lib/config'),
    workers = require('../lib/workers');

mongoose.Promise = Promise;

Promise.coroutine(function* () {
    yield config.load();
    var resources = [
            {res: 'Photo', path: '/photos', model: require('../models/photo').Photo}
        ],
        dburl = 'mongodb://' +
            config.get.mongodb.host + ':' +
            config.get.mongodb.port + '/' +
            config.get.mongodb.dbname;

    mongoose.connect(dburl);
    mongoose.model('Photo', require('../models/photo').Photo);

    console.log('connecting to ' + dburl);

    return Promise.resolve(mongoose.model('Photo').find({}))
        .map(function (photo) {
            return Promise.promisify(function (cb) {
                    gm('../assets/photos/' + photo.uuid)
                        .resize('200', '200', '^>')
                        .gravity('Center')
                        .crop('200', '200')
                        .write('../assets/photos/' + photo.uuid + '-thumb', function (err) {
                            cb(err);
                        });
                })();
        }, {concurrency: 1});
})();
@@ -147,41 +147,52 @@
     
-workers = require('../lib/workers
+gm = require('gm'),%0A    path = require('path
 ');%0A
@@ -862,16 +862,29 @@
      gm(
+path.resolve(
 '../asse
@@ -908,16 +908,17 @@
 to.uuid)
+)
 %0A       
@@ -1080,16 +1080,29 @@
  .write(
+path.resolve(
 '../asse
@@ -1136,16 +1136,17 @@
 '-thumb'
+)
 , functi
@@ -1241,16 +1241,121 @@
     %7D)()
+%0A                .catch(function (err) %7B%0A                    console.log(err.message);%0A                %7D)
 ;%0A      

remove queue from thumb script