private void Start()
        {
            #if !DEBUG
            using (var db = new RepoContext ())
            {
                var dbRepo = db.Repositories.SingleOrDefault (x => x.Name == _repository.FullName);
                if (null == dbRepo)
                {
                    dbRepo = new GitHook_Mono.Data.Models.Repository () {
                        Builds = 0,
                        Name = _repository.FullName
                    };
                    db.Repositories.Add (dbRepo);
                    db.SaveChanges ();
                }

                //Set the working repo id
                _repoId = dbRepo.Id;
                _builds = dbRepo.Builds;
            }
            #endif

            if (null == _processor || !_processor.IsAlive) _processor = new System.Threading.Thread (Processor);

            if (!_processor.IsAlive) _processor.Start ();
        }
        private void Processor()
        {
            while (_pending.Count > 0)
            {
                GitHub_Commit commit;
                if (_pending.TryDequeue (out commit))
                {
                    //Generate the clone directory
                    var cloneDirectory = GetProjectPath (commit.CommitId);

                    #if !DEBUG
                    using (var db = new RepoContext ())
                    {
                        var commit = db.Commits.SingleOrDefault (x => x.RepositoryId == _repoId && x.SHA == sha);
                        if (null == commit)
                        {
                            commit = new GitHook_Mono.Data.Models.Commit () {
                                RepositoryId = _repoId,
                                SHA = sha
                            };
                            db.Commits.Add (commit);
                        }

                        commit.Status = GitHook_Mono.Data.Models.CommitStatus.Processing;
                        db.SaveChanges ();
                    #endif
                    BuildConfig current = null;
                    try
                    {
                        var logPath = commit.CommitId + ".log";
                        var logger = new BuildLogger (logPath);

                        //Clone
                        logger.WriteLine ("Cloning...");
                        Clone (logger, cloneDirectory, commit);
                        logger.WriteLine ("Clone Completed.");

                        //Load config
                        var cfg = System.IO.Path.Combine (cloneDirectory, BuildFile);
                        BuildConfig[] config;
                        try
                        {
                            config = MainClass.LoadConfig<BuildConfig[]> (cfg);
                        }
                        catch
                        {
                            config = new BuildConfig[] { MainClass.LoadConfig<BuildConfig> (cfg) };
                        }
                        if (null == config)
                        {
                            logger.WriteLine ($"Failed to load configuration file at: {cfg}");
                            return;
                        }
            //						Console.WriteLine ("Config: " + config.ToString ());

                        foreach (var build in config)
                        {
                            current = build;
                            //For each build configuration we must ensure we are working with the freshest copy
                            Run (logger, "git", "reset --hard origin/master", cloneDirectory);

                            //Now that we have a clone, we can attempt to load some config
                            if (String.IsNullOrEmpty (build.SolutionFile))
                            {
                                var sln = System.IO.Directory.GetFiles (cloneDirectory, "*.sln");
                                if (sln != null && sln.Length > 0)
                                {
                                    if (sln.Length == 1)
                                    {
                                        /*if (config == null) build = new BuildConfig () {
                                                SolutionFile = sln.First ()
                                            };
                                        else*/
                                        build.SolutionFile = sln.First ();
                                    }
                                    else
                                    {
                                        throw new CompilerException (1, $"Too many solution files detected, please specify one in your {BuildFile}");
                                    }
                                }
                                else
                                {
                                    throw new CompilerException (1, $"No solution file specified in {BuildFile}");
                                }
                            }

                            //Start compilation
                            logger.WriteLine ("Compiling...");
                            Compile (logger, build, cloneDirectory, commit);
                            logger.WriteLine ("Compiling Completed.");

                            MainClass.Plugins.ForEachPlugin ((plugin) =>
                            {
                                plugin.OnPass (this, cloneDirectory, commit, current);
                            });
                        }

                        logger.Close ();
                        MainClass.Plugins.ForEachPlugin ((plugin) =>
                        {
                            plugin.LogClosed (this, logPath);
                        });
                        #if !DEBUG
                            commit.Status = GitHook_Mono.Data.Models.CommitStatus.Passed;
                        #endif
                    }
                    catch (CompilerException ex)
                    {
                        #if !DEBUG
                            commit.Status = GitHook_Mono.Data.Models.CommitStatus.Failed;
                        #endif
                        Console.WriteLine (ex.ToString ());

                        MainClass.Plugins.ForEachPlugin ((plugin) =>
                        {
                            plugin.OnFail (this, cloneDirectory, commit, current);
                        });
                    }
                    #if !DEBUG
                        db.Repositories.Single (x => x.Id == _repoId).Builds++;
                        _builds++;
                        db.SaveChanges ();
                    }
                    #endif
                }
            }
        }