single_instance

package
v3.0.0-alpha.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 9 Imported by: 0

README

single-instance Plugin

This plugin provides a way to prevent multiple launches of your application.

Installation

Add the plugin to the Plugins option in the Applications options:

    Plugins: map[string]application.Plugin{
        "single_instance": single_instance.NewPlugin(&single_instance.Config{
            // When true, the original app will be activated when a second instance is launched
            ActivateAppOnSubsequentLaunch: true,
        }
    },

Usage

This plugin prevents the launch of multiple copies of your application. If you set ActivateAppOnSubsequentLaunch to true the original app will be activated when a second instance is launched.

Support

If you find a bug in this plugin, please raise a ticket here. Please do not contact the Wails team for support.

Credit

This plugin contains modified code from the awesome go-singleinstance module (c) 2015 Allan Simon. Original license file has been renamed go-singleinstance.LICENSE and is available here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateLockFile

func CreateLockFile(filename string, PID int) (*os.File, error)

CreateLockFile tries to create a file with given name and acquire an exclusive lock on it. If the file already exists AND is still locked, it will fail.

func GetLockFilePid

func GetLockFilePid(filename string) (pid int, err error)

Types

type Config

type Config struct {
	// Add any configuration options here
	LockFileName                  string
	LockFilePath                  string
	ActivateAppOnSubsequentLaunch bool
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin(config *Config) *Plugin

func (*Plugin) Assets

func (p *Plugin) Assets() fs.FS

func (*Plugin) CallableByJS

func (p *Plugin) CallableByJS() []string

func (*Plugin) Exported

func (p *Plugin) Exported() []string

Exported returns a list of exported methods that can be called from the frontend

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the name of the plugin.

func (*Plugin) OnShutdown

func (p *Plugin) OnShutdown() error

OnShutdown is called when the app is shutting down

func (*Plugin) OnStartup

func (p *Plugin) OnStartup(ctx context.Context, options application.ServiceOptions) error

OnStartup is called when the app is starting up. You can use this to initialise any resources you need. You can also access the application instance via the app property.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL