Skip to content
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

[Help] how to run the built application and npm run dev at the same time? #375

Open
DenniLa2 opened this issue Apr 24, 2023 · 6 comments
Open
Labels
help wanted Extra attention is needed

Comments

@DenniLa2
Copy link

On macos unable to run built app and npm run dev at the same time.
If built app is running, then npm run dev returns
image
otherwise nothing happens.

@DenniLa2 DenniLa2 added the help wanted Extra attention is needed label Apr 24, 2023
@DenniLa2
Copy link
Author

Need comment this:

if (!app.requestSingleInstanceLock()) {
  app.quit()
  process.exit(0)
}

)

@caoxiemeihao
Copy link
Member

Maybe the following code is better.

- if (!app.requestSingleInstanceLock()) {
-   app.quit()
-   process.exit(0)
- }

@DenniLa2
Copy link
Author

Maybe the following code is better.

- if (!app.requestSingleInstanceLock()) {
-   app.quit()
-   process.exit(0)
- }

Indeed, allowing many instances if it is not required is a bad idea. So I decided to do this:

if (isDevMode()) {
  app.setName(`${app.name}-dev`)
}

if (!app.requestSingleInstanceLock()) {
  app.quit()
  process.exit(0)
}

@caoxiemeihao thanks

@DenniLa2
Copy link
Author

The compiled application and launched through npm run dev get one pid. Because of this, I cannot run both the built and developed applications at the same time.
@caoxiemeihao How to make the assembled application get a name not from package.json.name?

@caoxiemeihao
Copy link
Member

caoxiemeihao commented May 1, 2023

import { app } from 'electron'

app.getName()

@DenniLa2
Copy link
Author

DenniLa2 commented May 2, 2023

If I understand correctly, then the OS generates a PID based on the application name. When assembled, the name is taken from package.json.name. When I run the built app and when I run the app from npm run dev they have the same PID. Because of this, I can't run a built app and a development app at the same time.
But if I specify a different name when building in package.json.name, then the assembled application gets a different name. And, as a result, another PID. But it's not convenient.
I want to substitute a name during assembly that is different from what is in package.json.name. How to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants