Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Linux: Startup thread that launches node subprocess #278

Closed
wants to merge 7 commits into from
Closed

Linux: Startup thread that launches node subprocess #278

wants to merge 7 commits into from

Conversation

timburgess
Copy link
Contributor

This is some initial work in getting the node process up & running in Linux.

With this code, brackets-shell kicks off a mutexed launch thread that starts the Node executable in a subprocess.
As per the latest linux setup script, Node is launched from brackets-shell/deps/node/bin/node.

A file descriptor in the startup thread is piped to STDIN in the subprocess.
I have experimented with passing input to the node process to eval(). This works but Node appears to buffer it's output if it detects that STDIN is not a terminal. If I run node in interactive mode i.e. 'node -i' it stops buffering but produces a lot more output than I think is wanted.

I'd appreciate getting some feedback on how to run Node as then I can add code to setup a pipe from the subprocess STDOUT to a thread that reads the output.

@ghost ghost assigned jasonsanjose Jul 15, 2013
@jasonsanjose
Copy link
Member

cc @joelrbrandt to see if he has any thoughts. Assigned to @jasonsanjose.

@timburgess
Copy link
Contributor Author

I've done more work on this and now:

  • both read & write pipes implemented to subprocess
  • node subprocess starts and runs node-core & websockets established
  • eliminates node-related startup delay of multiple seconds (yay!)
  • node debugger working
  • no more StaticServer errors in console & 'Log Node State to Console' works

node restart is yet to be implemented and there are probably more syscall checks required

@thefirstofthe300
Copy link

I noticed a problem with the node setup script integrating with @timburgess's node setup. Tim's node setup seems to call node from the deps/node/bin directory. The grunt-mac command that linux piggy-backs calls a rename of the node binary to Brackets-node and therefore causes the entire setup to collapse unless a manual copy and rename of the Brackets-node binary to just node is done.

I think @timburgess will either want to adapt, or the grunt script needs to call a copy instead of rename.

@timburgess
Copy link
Contributor Author

Good point. When @jasonsanjose's grunt build PR goes into master, I will need to adjust to suit any path and or binary file name changes. At present, the code does run node from /deps/node/bin This is what the OS X build does but on OS X grunt produces a Brackets-node binary whereas the Linux script simply pulled down a binary named node. I have no issue with using the same structure as on OS X.

@jasonsanjose
Copy link
Member

@timburgess the Gruntfile.js changes landed. Would you like to update this pull?

@timburgess
Copy link
Contributor Author

Doing it right now :-)

@timburgess
Copy link
Contributor Author

With @jasonsanjose 's Sprint 29 in master, I have rebased from master and made changes to run deps/node/bin/Brackets-node. Running this against current brackets/master, I get zero errors in the console on startup (first time I've seen that on Linux!). @DaBungalow Could you try this as well?

I have been working on an extension with node-side code so will do some more testing to confirm that it works on Linux in the same way it does on OS X.

@timburgess
Copy link
Contributor Author

Tried a couple of extensions with node-side code. All works for me.

@jasonsanjose
Copy link
Member

Fantastic! I'll try this first thing tomorrow.

@joelrbrandt
Copy link
Contributor

@timburgess nice! thanks for your hard work.

@@ -49,6 +49,19 @@
#define NODE_CORE_PATH @"/Contents/node-core"

#endif
#ifdef OS_LINUX
//#define GROUP_NAME @""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Nevermind, I see this is a placeholder for OS-specific preferences. I'll add a TODO.

@jasonsanjose
Copy link
Member

Closing, see #306.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants