Skip to content

Commit

Permalink
Clean up Pathing and code base (#15)
Browse files Browse the repository at this point in the history
* Move Entitlements out of assets folder

entitlements should not be packaged into built app

* SubWorkflows need 'workflow_call'

Removed Push as it is redundant as debug all will build all 3 on push.

* fix pathing for .env in assets

* fix typo

---------

Co-authored-by: telamonian <[email protected]>
  • Loading branch information
KenCorma and telamonian authored Sep 11, 2024
1 parent 7446c7d commit 8d4648b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/macos/signwheel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
shell: sh
run: |
cd ./assets/python/wheels
find . -name "*so" -o -name "*.dylib" -print0 | while read -d $'\0' file; do codesign --sign 6698D856280DC1662A8E01E5B63428CB6D6651BB --force --timestamp --options runtime --entitlements ../../entitlements.mac.plist "$file"; done
find . -name "*so" -o -name "*.dylib" -print0 | while read -d $'\0' file; do codesign --sign 6698D856280DC1662A8E01E5B63428CB6D6651BB --force --timestamp --options runtime --entitlements ../../../scripts/entitlements.mac.plist "$file"; done
- name: Repack
shell: sh
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/debug_linux.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build App Linux Debug

on:
push:
branches:
- main
workflow_dispatch:
workflow_call:
pull_request:
branches:
- main
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/debug_macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .github/workflows/debug_macos.yml
name: Build App Macos Debug

on:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/debug_windows.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build Windows Debug
name: Build App Windows Debug

on:
push:
branches:
- main
workflow_dispatch:
workflow_call:
pull_request:
branches:
- main
Expand Down
6 changes: 3 additions & 3 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FuseV1Options, FuseVersion } from '@electron/fuses';
const config: ForgeConfig = {
packagerConfig: {
asar: true,
...process.env.PUBLISH == 'true' && {
...process.env.PUBLISH == 'true' && {
windowsSign: {
debug:true,
hookFunction: (filePath) => {
Expand All @@ -23,7 +23,7 @@ const config: ForgeConfig = {
osxSign: {
identity: process.env.SIGN_ID,
optionsForFile: (filepath) => {
return { entitlements: './assets/entitlements.mac.plist' };
return { entitlements: './scripts/entitlements.mac.plist' };
}
},
osxNotarize: {
Expand All @@ -32,7 +32,7 @@ const config: ForgeConfig = {
teamId: process.env.APPLE_TEAM_ID
},
},
extraResource: ['./assets/UI', './assets/ComfyUI', './assets/python.tgz'],
extraResource: ['./assets/ComfyUI', './assets/python.tgz', './assets/UI'],

icon: process.platform === 'linux' ? 'assets/UI/Comfy_Logo_x128.png' : 'assets/UI/Comfy_Logo',
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"packageManager": "[email protected]",
"scripts": {
"clean": "rimraf .vite dist out",
"clean:assets": "rimraf assets/.env assets/ComfyUI assets/python.tgz && yarn run clean:assets:dev",
"clean:assets:dev": "rimraf assets/python assets/override.txt | rimraf assets/cpython*.tar.gz | rimraf assets/requirements.*",
"clean:assets": "rimraf assets/.env assets/ComfyUI assets/python.tgz & yarn run clean:assets:dev",
"clean:assets:dev": "rimraf assets/python assets/override.txt & rimraf assets/cpython*.tar.gz & rimraf assets/requirements.*",
"clean:slate": "yarn run clean && yarn run clean:assets && rimraf node_modules",
"lint": "eslint --ext .ts,.tsx .",
"lint:fix": "eslint --fix --ext .ts,.tsx .",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const envContent = `# env vars picked up by the ComfyUI executable on startup
COMFYUI_CPU_ONLY=true
`

fs.writeFile(".env", envContent);
fs.writeFile("ComfyUI/.env", envContent);
20 changes: 10 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const createWindow = () => {
mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));

// Set up the System Tray Icon for all platforms
// Returns a tray so you can set a global var to access.
// Returns a tray so you can set a global var to access.
SetupTray(mainWindow);

// Overrides the behavior of closing the window to allow for
// Overrides the behavior of closing the window to allow for
// the python server to continue to run in the background
mainWindow.on('close' , (e:Electron.Event) => {
e.preventDefault();
Expand Down Expand Up @@ -105,7 +105,7 @@ const launchPythonServer = async (args: {userResourcesPath: string, appResources
console.log('Python server is already running');
// Server has been started outside the app, so attach to it.
setTimeout(() => {
// Not sure if needed but wait a few moments before sending the connect message up.
// Not sure if needed but wait a few moments before sending the connect message up.
webContents.getAllWebContents()[0].send("python-server-status", "active");
}, 5000);
clearInterval(serverHeartBeatReference);
Expand Down Expand Up @@ -175,14 +175,14 @@ const launchPythonServer = async (args: {userResourcesPath: string, appResources
const checkServerReady = async () => {
currentWaitTime += 1000;
if (currentWaitTime > maxFailWait) {
//Something has gone wrong and we need to backout.
//Something has gone wrong and we need to backout.
clearTimeout(spawnServerTimeout);
reject("Python Server Failed To Start");
}
const isReady = await isPortInUse(host, port);
if (isReady) {
console.log('Python server is ready');
// Start the Heartbeat listener, send connected message to Renderer and resolve promise.
// Start the Heartbeat listener, send connected message to Renderer and resolve promise.
serverHeartBeatReference = setInterval(serverHeartBeat, serverHeartBeatInterval);
webContents.getAllWebContents()[0].send("python-server-status", "active");
//For now just replace the source of the main window to the python server
Expand Down Expand Up @@ -217,7 +217,7 @@ app.on('ready', async () => {
console.log(`appResourcesPath: ${appResourcesPath}`);

try {
dotenv.config({path: path.join(appResourcesPath, ".env")});
dotenv.config({path: path.join(appResourcesPath, "ComfyUI", ".env")});
} catch {
// if no .env file, skip it
}
Expand All @@ -227,7 +227,7 @@ app.on('ready', async () => {
} catch {
// if user-specific resources dir already exists, that is fine
}
try {
try {
createWindow();
await launchPythonServer({userResourcesPath, appResourcesPath});
} catch (error) {
Expand All @@ -239,21 +239,21 @@ const killPythonServer = () => {
console.log('Python server:', pythonProcess);
return new Promise<void>(async(resolve, reject) => {
if (pythonProcess) {
try {
try {
pythonProcess.kill();
setTimeout(() => {
resolve(); // Force the issue after 5seconds
}, 5000);
// Make sure exit code was set so we can close gracefully
while (pythonProcess.exitCode == null)
{}
resolve();
resolve();
}
catch(error)
{
console.error(error);
reject(error);
}
}
}
else
{
Expand Down

0 comments on commit 8d4648b

Please sign in to comment.