-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make "machine ID" easier to supply on import
- Loading branch information
Showing
4 changed files
with
46 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package import_cmdline | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/turt2live/matrix-media-repo/util/ids" | ||
"golang.org/x/term" | ||
) | ||
|
||
func AskMachineId() { | ||
fmt.Println("The importer runs as a MMR worker and needs to have a dedicated MACHINE_ID. See https://docs.t2bot.io/matrix-media-repo/deployment/horizontal_scaling.html for details on what a MACHINE_ID is.") | ||
if !term.IsTerminal(int(os.Stdin.Fd())) { | ||
fmt.Println("Please specify a MACHINE_ID environment variable.") | ||
os.Exit(2) | ||
return // for good measure | ||
} | ||
fmt.Println("If you don't use horizontal scaling, you can use '1' as the machine ID. Otherwise, please enter an unused machine ID in your environment.") | ||
fmt.Printf("Machine ID: ") | ||
var machineId int64 | ||
if _, err := fmt.Scanf("%d", &machineId); err != nil { | ||
panic(err) | ||
} | ||
if err := ids.SetMachineId(machineId); err != nil { | ||
panic(err) | ||
} | ||
} |
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