public static function lock($log)
 {
     $lock_file = BASE_PATH . '/.lock';
     // check if lock file exists
     if (file_exists($lock_file)) {
         // get pid of locking process
         self::$_PID = file_get_contents($lock_file);
         // check if we locked it by ourselfs
         if (self::$_PID == getmypid()) {
             return TRUE;
         }
         // check if process is still running
         if (self::running()) {
             $log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector is still running with pid " . self::$_PID);
             return FALSE;
         } else {
             $log->log(\Psr\Log\LogLevel::ERROR, "AIESEC-Customer.io-Connector died. Please look into this accident and then manually delete the .lock-file");
             die;
         }
     } else {
         // get our own pid
         self::$_PID = getmypid();
         // try to get the lock
         if (file_put_contents($lock_file, self::$_PID) > 0) {
             // sleep 1s
             sleep(1);
             // check that we really got the lock
             if (self::$_PID == file_get_contents($lock_file)) {
                 $log->log(\Psr\Log\LogLevel::INFO, "Process " . self::$_PID . " locked the base directory");
                 return self::$_PID;
             } else {
                 $log->log(Psr\Log\LogLevel::WARNING, "Some process overwrote the lock for process " . self::$_PID);
                 return FALSE;
             }
         } else {
             $log->log(\Psr\Log\LogLevel::ERROR, "Couldn't write lock-file. Please make the base directory writeable for the php process");
         }
     }
 }