-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: remove .lock file when abe restart to unlock processes
- Loading branch information
nicolaslabbe
committed
Oct 20, 2016
1 parent
a1e0acf
commit 1013c28
Showing
4 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import hooks from './hooks' | ||
import plugins from './plugins' | ||
import process from './process' | ||
import * as lock from './lock' | ||
|
||
export { | ||
hooks | ||
,plugins | ||
,process | ||
,lock | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import process from 'child_process' | ||
import path from 'path' | ||
import fs from 'fs' | ||
|
||
import { | ||
config | ||
,abeExtend | ||
} from '../' | ||
|
||
export function create(name) { | ||
let lockFile = path.join(config.root, `abe-process-${name}.lock`) | ||
try { | ||
var stats = fs.statSync(lockFile) | ||
if (stats.isFile()) { | ||
console.log(`cannot lock process ${name} already running`) | ||
return false | ||
} | ||
}catch(err) { | ||
fs.writeFileSync(lockFile, '', {encoding: 'utf8'}) | ||
} | ||
|
||
return true | ||
} | ||
|
||
export function remove(name) { | ||
let lockFile = path.join(config.root, `abe-process-${name}.lock`) | ||
try { | ||
var stats = fs.statSync(lockFile) | ||
if (stats.isFile()) { | ||
fs.unlinkSync(lockFile) | ||
return true | ||
} | ||
}catch(err) { | ||
|
||
} | ||
return false | ||
} | ||
|
||
export function deleteAll() { | ||
var files = fs.readdirSync(config.root) | ||
Array.prototype.forEach.call(files, (file) => { | ||
if (file.indexOf('abe-process') > -1 && file.indexOf('.lock') > -1) { | ||
fs.unlinkSync(path.join(config.root, file)) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters