Headless OSX Server: "Not allowed access to the window system right now"

We have a Mac Mini that we use as a server for a Node application.

The Node application launches some other native Mac apps and interacts with them. One of the apps is reporting kCGErrorFailure: This user is not allowed access to the window system right now and refuses to launch - until we RDP in and (presumably after initializing the window system) the whole thing starts working as expected.

It seems like some apps just freeze until the window system is 'nudged' by the RDP login.

Is there a way to get the window system working without having the sign in all the time?

The systems run headless and with as many as 16 users per box running simultaneously, with a Node app and associated software running under each user account.


Turns out this is due to the Node app spawning the Mac application in the headless state. We ended up launching the Mac app via launchd and not forcing it to be a child/parent process.