Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(991)

Side by Side Diff: mmutex/cmd/mmutex/exclusive.go

Issue 2980603003: Flesh out the mmutex binary wrapper and test for existence of lockfile (Closed)
Patch Set: Change tempdir directory to work on Windows Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mmutex/cmd/mmutex/.gitignore ('k') | mmutex/cmd/mmutex/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package main
6
7 import (
8 "fmt"
9 "os"
10
11 "github.com/maruel/subcommands"
12
13 "github.com/luci/luci-go/mmutex/lib"
14 )
15
16 var cmdExclusive = &subcommands.Command{
17 UsageLine: "exclusive -- <command>",
18 ShortDesc: "acquires an exclusive lock before running the command",
19 CommandRun: func() subcommands.CommandRun {
20 return &cmdExclusiveRun{}
21 },
22 }
23
24 type cmdExclusiveRun struct {
25 subcommands.CommandRunBase
26 }
27
28 func (c *cmdExclusiveRun) Run(a subcommands.Application, args []string, env subc ommands.Env) int {
29 // TODO(charliea): Make sure that `args` has length greater than zero.
30
31 if err := lib.AcquireExclusiveLock(lockFilePath); err != nil {
32 fmt.Fprintf(os.Stderr, "error acquiring exclusive lock: %s\n", e rr)
33 return 1
34 }
35
36 return 0
37 }
OLDNEW
« no previous file with comments | « mmutex/cmd/mmutex/.gitignore ('k') | mmutex/cmd/mmutex/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698