| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. | 1 // Copyright 2017 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 package main | 15 package main |
| 16 | 16 |
| 17 import ( | 17 import ( |
| 18 "os" | 18 "os" |
| 19 "path" |
| 19 | 20 |
| 20 "github.com/maruel/subcommands" | 21 "github.com/maruel/subcommands" |
| 21 ) | 22 ) |
| 22 | 23 |
| 23 // TODO(charliea): Compute this path from $MMUTEX_LOCK_DIR rather than using a c
onstant. | 24 // TODO(charliea): Compute this path from $MMUTEX_LOCK_DIR rather than making it
fixed. |
| 24 const lockFilePath = "/tmp/lock" | 25 var LockFilePath = path.Join(os.TempDir(), "mmutex.lock") |
| 25 | 26 |
| 26 var application = &subcommands.DefaultApplication{ | 27 var application = &subcommands.DefaultApplication{ |
| 27 Name: "mmutex", | 28 Name: "mmutex", |
| 28 Title: `'Maintenance Mutex' - Global mutex to isolate maintenance tasks. | 29 Title: `'Maintenance Mutex' - Global mutex to isolate maintenance tasks. |
| 29 | 30 |
| 30 mmutex is a command line tool that helps prevent maintenance tasks from running | 31 mmutex is a command line tool that helps prevent maintenance tasks from running |
| 31 during user tasks. The tool does this by way of a global lock file that users | 32 during user tasks. The tool does this by way of a global lock file that users |
| 32 must acquire before running their tasks. | 33 must acquire before running their tasks. |
| 33 | 34 |
| 34 Clients can use this tool to request that their task be run with one of two | 35 Clients can use this tool to request that their task be run with one of two |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 https://github.com/luci/luci-go/tree/master/mmutex`, | 47 https://github.com/luci/luci-go/tree/master/mmutex`, |
| 47 Commands: []*subcommands.Command{ | 48 Commands: []*subcommands.Command{ |
| 48 cmdExclusive, | 49 cmdExclusive, |
| 49 subcommands.CmdHelp, | 50 subcommands.CmdHelp, |
| 50 }, | 51 }, |
| 51 } | 52 } |
| 52 | 53 |
| 53 func main() { | 54 func main() { |
| 54 os.Exit(subcommands.Run(application, nil)) | 55 os.Exit(subcommands.Run(application, nil)) |
| 55 } | 56 } |
| OLD | NEW |