I see this question has been asked but the context of that question is different and so there are no answers relavent to my use case so I'm asking a new question
I have an Electron based Web Server. It's meant for beginning web developers, students, and artists that are not used to the command line (yes that's a huge debate right there but I was scolded by the teachers at the Art and Design School at UCLA for asking their students to use the command line, hence a simple server with a GUI. Please don't debate this point. It's not the point of the question)
In any case, people using this web server sometimes want to run on port 80. On Mac (and Linux?) port 80 requires admin rights and so I'd like to escalate the server's permissions to do this.
My understanding is the easiest (only?) way to do this is to spawn another process. Since the server part of my web server is effectively written in node.js and since node.js (or at least the API) is built into Electron then it seems like the best solution would be to just re-spawn my Electron app to run only the server portion.
In other words, imagine I could run the app like
/Applications/Servez.app/Contents/MacOS/Servez --no-gui --server-only --port 80
Then I could use some spawn command on Mac like
/usr/bin/osascript -e '
do shell "/Applications/Servez.app/Contents/MacOS/Servez --no-gui --server-only --port 80" with administrator privileges
'
And macOS will ask for admin privileges before running the server.
If I can't run Electron with no GUI then I could include a copy of node.js inside the Electron package but it seems like a huge waste of space given the same functionality is already inside Electron. Or maybe there is some other solution? (some API call I can make to ask for permission to use port 80?)
Setting the environment variable ELECTRON_RUN_AS_NODE
will run Electron as node so I can just set that environment variable when spawning Electron