-
Notifications
You must be signed in to change notification settings - Fork 1
fix: second instance return false #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks for this @huanguan1978 I will have to review it against my app, and the other "single instance" code bases. Let me know if you need me to hurry on that - I have a couple other things to look into. |
// ---- example from example/unix_single_instance_example.dart void main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isLinux) {
if (!await unixSingleInstance(arguments, cmdProcessor)) { // <-- error: this function call exit(0), nothing return.
exit(0);
return;
}
} else if (Platform.isMacOS) {
if (!await unixSingleInstance(arguments, cmdProcessor)) {
exit(0);
return;
}
}
runApp(const MyApp());
} // My First Instance Launching lib/main.dart on macOS in release mode... Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
flutter: ---main--- args:, [--action, list, --source, ~/Documents/Projects/avatar/filetimes]
flutter: ---main---, EnvArg.action: list
flutter: ---main---, EnvArg.source: ~/Documents/Projects/avatar/filetimes
flutter: Found existing instance!
flutter: Socket connect error
flutter: SocketException: Connection failed (OS Error: Connection refused, errno = 61), address = /Users/kaguya/Library/Containers/com.iche2.filetimes/Data/Documents/socket, port = 0
flutter: Deleting dead socket
flutter: creating socket
flutter: creating listening
flutter: Event
flutter: Instance of '_Socket'
flutter: Second instance launched with: ["--action","list","--source","~/Documents/Projects/avatar/filetime"]
flutter: ---cmdProcessor---, decodedArgs.forEach, --action
flutter: ---cmdProcessor---, decodedArgs.forEach, list
flutter: ---cmdProcessor---, decodedArgs.forEach, --source
flutter: ---cmdProcessor---, decodedArgs.forEach, ~/Documents/Projects/avatar/filetime
flutter: ---cmdProcessor---, argsToMap, {action: list, source: ~/Documents/Projects/avatar/filetime} // -------------------------------------------------------------------------------- Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
flutter: ---main--- args:, [--action, list, --source, ~/Documents/Projects/avatar/filetime]
flutter: ---main---, EnvArg.action: list
flutter: ---main---, EnvArg.source: ~/Documents/Projects/avatar/filetime
flutter: Found existing instance!
flutter: Message sent
flutter: Quiting. // <— fix: Second Instance output message ' Quiting' and exit(0), not return false. |
Hey @huanguan1978 no debate required. I agree I just need to do due diligence. Although what you provided is actually useful. Thanks. Do you need this merged and released ASAP or can you wait? |
Thanks @arran4 , please merge this. Also, I have a few questions. Could you provide guidance? Based on your logic, upon startup, 'First Instance' checks for the file 'socket'. If it exists, it displays 'Found existing instance!' then deletes and recreates it. Is there a method to reuse this socket, similar to MySQL?" flutter: Found existing instance!
flutter: Socket connect error
flutter: SocketException: Connection failed (OS Error: Connection refused, errno = 61), address = /Users/kaguya/Library/Containers/com.iche2.filetimes/Data/Documents/socket, port = 0
flutter: Deleting dead socket
flutter: creating socket
flutter: creating listening |
Are you looking to use a custom message? -- What do you want to reuse it for? |
I envision a GUI application running as a single instance, controlled dynamically via command-line arguments. This would enable actions like adding/removing/starting/stopping scheduled tasks, and viewing task logs from within the instance. The core of this control mechanism should be implemented using Unix sockets.👍 |
No description provided.