The goal of this project is to have a desktop application built with Electron where all the real work happens in the bundled Actionhero.
This project supports a multiprocess architecture with multiple actionheros running in background browserwindows. They all share a single fakeredis by way of electron's remote module. To disable the background processes set NUM_BACKGROUND_PROCS to 0 in index.js.
To demonstrate the multiprocess architecture I have created a task in actionhero/tasks/check.js which runs about every second.
The task scheduler is running in the electron main process actionhero instance. It queues the task for running every second.
Background workers are watching the queue to execute the tasks. Watch the logs to see the background workers collaborating to run tasks from the queue.
Notable files:
index.js: set up application and start main processbg.html: main entry point for the background worker processesactionhero/config/redis.js: manage fakeredis module via electron remote
How this project was bootstrapped:
- Started with electron-boilerplate
- Installed actionhero via NPM
- Generated the sample Actionhero project structure and moved it into the
actionherodirectory - Edited the resource paths in
chat.htmlto be relative to that file - Set the hostname for Actionhero server to
http://localhost:8080inchat.html
New code written to boot actionhero (in /index.js):
extractActionhero(): extracts/actionheroto a user-writable appData folder. see actionhero/readme.md for details.startActionhero(callback): setsPROJECT_ROOTenvironment variable to extracted folder then starts up actionhero, which runscallbackwhen finished booting.- Hooked actionhero startup into the electron
readyevent and delayed creating the main window until after actionhero is started - Pointed the main window at
actionhero/public/chat.htmlin the extracted folder
$ npm install
$ npm start
Package without using ASAR
$ npm run build
Package using ASAR
$ npm run build-asar
Builds the app for macOS-x64, using electron-packager.
Will expand support for Windows & Linux soon.
Many thanks to the Actionhero community. We worked together to fix a couple bugs that had prevented actionhero from running in an ASAR package. See release notes for details.
Thanks also to Github for Electron and, well, for Github.
MIT © Louis Zuckerman