Additional keepalive fixes.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bodyshop-desktop",
|
"name": "bodyshop-desktop",
|
||||||
"version": "0.0.1-alpha.8",
|
"version": "0.0.1-alpha.10",
|
||||||
"description": "Shop Management System Partner",
|
"description": "Shop Management System Partner",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "Convenient Brands, LLC",
|
"author": "Convenient Brands, LLC",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
|||||||
<string>com.convenientbrands.bodyshop-desktop.keepalive</string>
|
<string>com.convenientbrands.bodyshop-desktop.keepalive</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>open</string>
|
<string>Shop Partner Keep Alive</string>
|
||||||
<string>imexmedia://keep-alive</string>
|
<string>imexmedia://keep-alive</string>
|
||||||
</array>
|
</array>
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
@@ -30,8 +30,8 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
|||||||
</plist>`;
|
</plist>`;
|
||||||
|
|
||||||
const plistPath = join(
|
const plistPath = join(
|
||||||
homedir(),
|
homedir(),
|
||||||
"Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
"/Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -40,15 +40,17 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
|||||||
log.info(`Launch agent created and loaded: ${stdout}`);
|
log.info(`Launch agent created and loaded: ${stdout}`);
|
||||||
if (stderr) log.warn(`Launch agent stderr: ${stderr}`);
|
if (stderr) log.warn(`Launch agent stderr: ${stderr}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`Error setting up launch agent: ${error instanceof Error ? error.message : String(error)}`);
|
log.error(
|
||||||
|
`Error setting up launch agent: ${error instanceof Error ? error.message : String(error)}`,
|
||||||
|
);
|
||||||
throw error; // Rethrow to allow caller to handle
|
throw error; // Rethrow to allow caller to handle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
||||||
const plistPath = join(
|
const plistPath = join(
|
||||||
homedir(),
|
homedir(),
|
||||||
"Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
"/Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||||
);
|
);
|
||||||
const maxRetries = 3;
|
const maxRetries = 3;
|
||||||
const retryDelay = 500; // 500ms delay between retries
|
const retryDelay = 500; // 500ms delay between retries
|
||||||
@@ -56,10 +58,14 @@ export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
|||||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
try {
|
try {
|
||||||
await fs.access(plistPath, fs.constants.F_OK);
|
await fs.access(plistPath, fs.constants.F_OK);
|
||||||
const { stdout } = await execPromise(`launchctl list | grep com.convenientbrands.bodyshop-desktop.keepalive`);
|
const { stdout } = await execPromise(
|
||||||
|
`launchctl list | grep com.convenientbrands.bodyshop-desktop.keepalive`,
|
||||||
|
);
|
||||||
return !!stdout; // Return true if plist exists and agent is loaded
|
return !!stdout; // Return true if plist exists and agent is loaded
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.debug(`Launch agent not found (attempt ${attempt}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`);
|
log.debug(
|
||||||
|
`Launch agent not found (attempt ${attempt}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`,
|
||||||
|
);
|
||||||
if (attempt === maxRetries) {
|
if (attempt === maxRetries) {
|
||||||
return false; // Return false after all retries fail
|
return false; // Return false after all retries fail
|
||||||
}
|
}
|
||||||
@@ -68,4 +74,4 @@ export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false; // Fallback return
|
return false; // Fallback return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user