 		
 	#if swift(>=3)
 		
-		if(FileManager.default().fileExists(atPath: pidFile)) {
-			
+	#if os (Linux)
+		let pidFileExists = NSFileManager.defaultManager().fileExists(atPath: pidFile)
+	#else
+		let pidFileExists = FileManager.default().fileExists(atPath: pidFile)
+	#endif
+		if(pidFileExists) {
+			
+		#if os (Linux)
+			let pidFileDescriptor = NSFileHandle(forReadingAtPath: pidFile)
+		#else
 			let pidFileDescriptor = FileHandle(forReadingAtPath: pidFile)
+		#endif
 			if(pidFileDescriptor == nil) {
 				
 				return -1
 			}else{
+				
+			#if os (Linux)
+				pidFileDescriptor?.seekToFileOffset(0)
+			#else
 				pidFileDescriptor?.seek(toFileOffset: 0)
+			#endif
 				
 				if let pidData = pidFileDescriptor?.readDataToEndOfFile() {
 					
+				#if os (Linux)
+					let pidStr = String(data: pidData, encoding: NSUTF8StringEncoding)
+				#else
 					let pidStr = String(data: pidData, encoding: String.Encoding.utf8)
+				#endif
 					pidFileDescriptor?.closeFile()
 					
 					if let pidVal = Int32(pidStr!) {

	private func deletePid() {
		
	#if swift(>=3)
		
		if(FileManager.default().fileExists(atPath: pidFile)) {
			
			do {
		
				try FileManager.default().removeItem(atPath: pidFile)
			} catch _ {
				
				
				logger.writeLog(level: Logger.LogLevels.ERROR, message: "Could not delete pid file!")
			}
		}else{
			
			
			logger.writeLog(level: Logger.LogLevels.WARNINGS, message: "Pid file does not exists!")
		}
	#elseif swift(>=2.2) && os(OSX)

		if(NSFileManager.defaultManager().fileExistsAtPath(pidFile)) {
			
			do {

				try NSFileManager.defaultManager().removeItemAtPath(pidFile)

		
	#if swift(>=3)
		
	#if os (Linux)
		let pidFileExists = NSFileManager.defaultManager().fileExists(atPath: pidFile)
	#else
		let pidFileExists = FileManager.default().fileExists(atPath: pidFile)
	#endif
		if(pidFileExists) {
			
			kill(pid, SIGINT)
			throw AppWorkerError.PidFileExists
		}else{
		
		#if os (Linux)
			let createStatus = NSFileManager.defaultManager().createFile(atPath: pidFile, contents: nil, attributes: nil)
		#else
			let createStatus = FileManager.default().createFile(atPath: pidFile, contents: nil, attributes: nil)
		#endif
			if(!createStatus) {
				
				kill(pid, SIGINT)
				throw AppWorkerError.PidFileIsNotWritable
			}
			
		#if os (Linux)
			let pidFileDescriptor = NSFileHandle(forWritingAtPath: pidFile)
		#else
			let pidFileDescriptor = FileHandle(forWritingAtPath: pidFile)
		#endif
			if(pidFileDescriptor == nil) {
				kill(pid, SIGINT)
				throw AppWorkerError.PidFileIsNotWritable
