How to autorestart node.js application in Eclipse/Aptana Studio on source change while development? - eclipse

This is not a question really, but a guide in some sense.
I did not find a better place to post it. I hope someone finds this helpful.
I was fed up with stopping and starting node.js application to pick up code changes.
So I wanted a solution without too much hassle and installation of additional plug-ins, packages or anything else. The pure solution using standard Aptana Studio 3.4 (Eclipse) features on Windows 8.1 x64 as follows:
Right-click on your project in Project Explorer > Properties > Builders
New... > Program > OK
Name: Terminate existing node.js process(es)
Location: C:\Windows\System32\taskkill.exe (${env_var:SystemRoot}\System32\taskkill.exe did not work for me, it might for you)
Working Directory: Browse Workspace... > select your project > OK
Arguments: /IM node.exe /F
Switch to Build Options tab and tick During auto builds, untick Launch in background > OK
Create another builder: New... > Program > OK
Name: Start <your-project-name>
Location: C:\Program Files\nodejs\node.exe (you can try ${env_var:ProgramFiles}\nodejs\node.exe as well)
Working directory: same as point #5
Arguments: app.js (or any other file for application entry point)
Switch to Build Options tab and tick both During auto builds and Launch in background > OK
Turn on project autobuild: Window > Preferences > General > Workspace, tick Build automatically > OK
Change default build order: Window > Preferences > General > Workspace > Build Order, untick Use default build order and remove all projects except your node.js project > OK
Restart Aptana/Eclipse (There are bugs, so sometimes preference changes are just not saved and get lost. You have to double-check.)
So if you have not changed too many default preferences in Aptana Studio 3/Eclipse by saving a file within your project should trigger its builders. First builder will kill existing instance to overcome 'port already in use' exception and start an application again. Console tab related to that process should pop up.
This works perfectly for me developing one node.js project at a time and medium size application restarts instantly. There is still space for improvements, e.g. killing just that particular instance instead of all. Suggestions are welcome (except the ones to install Nodeclipse or node.js packages, etc.)!
I hope this easy to do solution will help someone. Also I hope Aptana Studio 3 will start supporting node.js type of projects/server natively very soon.

You can use nodemon to restart node application whenever the code changes. Have a look https://github.com/remy/nodemon/

Welcome to Nodeclipse. Your solution is added to Nodeclipse Help Run page,
please edit. That is to answer "a better place to post it".
Alternatively, this question should have been broken into problem and solution part to fit stackoverflow.com Q&A format. Also constrains (like without plugin or Node.js modules) should be said in the topic as some percentage of stackoverflow.com users don't really read whole (especially long) question.
Then my answer is just use Debug View. (Actually it should be named Launch as it is both for Run and Debug) In your favorite perspective: Window -> Show View -> Others.. -> Debug. (In Nodeclipse Node perspective Debug View is visible by default)
Then you can right-click on launched application in Debug View and select Terminate and Relaunch. That is more explicit and allows to run many applications.
I also don't understand why you first say "without plugins" and don't suggest "to install Nodeclipse", but in the end add "I hope Aptana Studio 3 will start supporting". Wouldn't it be another plugin/extension? Nodeclipse as of 0.10 has code completion for base Node.js modules and improved support for black background color themes. Open an issue when ready to discuss/work together. Nodeclipse was started by developers like you who stopped hoping and waiting and just did it. One small piece at a time. Just like you did.

My two cents:
If you want to enable debugging too, you can do it by creating a Standalone V8 VM configuration and launching it with eclipse_remote_control. Steps:
Help > Install new software...
Work with: https://github.com/marook/eclipse-remote-control/raw/master/workspaces/erc/update_site
Select and install the plugin
Important: download eclipse_remote_control_client.jar form https://github.com/marook/eclipse-remote-control/raw/master/workspaces/erc/release/eclipse_remote_control_client_1.3.0.jar and place it where you later know (I placed in /Applications/eclipse/plugins/eclipse_remote_control_client_1.3.0.jar)
Restart eclipse
Once installed the new plugin, create a new debug configuration and project builder:
Run > Debug Configurations... > Right click Standalone V8 VM > New
Name: NodeV8-5858 (or whatever, remember it)
Port: 5858
Apply, Close
Project Explorer > Right click your project > Properties > Builders
New... > Program > Ok
Name: Start NodeV8
Location: /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/bin/java (find your java location)
Working Directory: Browse Workspace... > select your project > OK
Arguments: -jar /Applications/eclipse/plugins/eclipse_remote_control_client_1.3.0.jar execute_command NodeV8-5858 DEBUG (replace with your .jar location and the name you selected in step 2)
Ok (then make sure that "Start NodeV8" remains the last entry in the list)
Select "Start " and click Edit...
Arguments: --debug-brk=5858 --harmony app.js (or any other file for application entry point)
Arguments: --debug=5858 --harmony app.js (if you don't want it to
wait at the beggining)
Ok and enjoy!
If you are working with mac, then to kill all node process you can create an script killallnode.sh with the following code:
#!/bin/bash
killall node
Place it somewhere you know and fill it in the location field for step 4.

Related

Setting up libgdx in IntelliJ Idea with GWT Support?

So far the documentation doesn't include the set up of GWT project in IDEA, and my limited google skill can't find the solution. Is it possible?
If you generated your libgdx project using the gdx-setup.jar file, then you should import your project by using the following link: https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA
HTML: View -> Tool Window -> Terminal, in the terminal, make sure you are in the root folder of your project. Then execute gradlew.bat html:superDev (Windows) or ./gradlew html:superDev (Linux, Mac OS X). This will take a while, as your Java code is compiled to Javascript.
Once you see the message The code server is ready, fire up your browser and go to http://localhost:8080/html. This is your app running in the browser! When you change any of your Java code or assets, just click the SuperDev refresh button while you are on the site and the server will recompile your code and reload the page! To kill the process, simply press CTRL + C in the terminal window.
Once this bug in the Gradle tooling API is fixed, we can simplify running the HTML5 by using the Gradle integration. At the moment, the Gradle process will run forever even if canceled.
Also just a heads up, after you have run the gradle command it might say something like this:
The code server is ready.
Next, visit: http://localhost:9876/
Building 91% > :html:superDev
Even though it says 91%, don't worry it will still work, just go here to run it: http://localhost:8080/html/, NOT the url mentioned in the log.
Also to deploy you need to run ./gradlew html:dist to generate production code, you want to copy everything inside ./html/build/dist/ to your server. Running that command produces the code in that directory. https://gamedev.stackexchange.com/a/82588/54396
I was able to make GWT work with libgdx simply by:
downloading (http://www.gwtproject.org/download.html) the GWT SDK,
extracting it,
then in the project structure -> project-name-html -> dependencies,
just press the + and add the extracted GWT directory
A dialog appears and I just unticked all the samples
The "Dependencies Storage Format" needed to be "Intellij IDEA", not Eclipse for this to work for me.

Need help setting up a (Tomcat) web app in Eclipse for debugging

I've been using both eclipse and tomcat for years but have always deployed my web apps externally and never had a problem. Now I'd like to use eclipse to debug my web app and I can't figure out how to make it work. I started by trying to get my existing web app to deploy through eclipse but after hours of trying different things I decided to start fresh. Unfortunately, I didn't get much further. I'm hoping if I can figure out how things work with a fresh webapp I can get things to work on my existing. Sorry, this will be long, but here are the steps I tried on the latest eclipse (Juno):
Installed new version of tomcat 7.0.34 at /usr/java.
In eclipse, used "servers" view to add server, pointing to the new install (I didn't add any resources because there weren't any available yet). Starting the server worked and got a 404 as expected at http://localhost:8080/ ... then I stopped it.
Created a new "dynamic web project", named it TomcatDebug, set the location to ~/tomcat-debug, chose the server just created above (the only one), chose default config, tomcat-debug is empty so chose defaults for build paths, defaults for module settings and had it generate web.xml.
In the "tomcat-debug" folder it creates WebContent, build, and src. I throw a sample "hello, world" index.html into WebContent.
Now the project TomcatDebug is created so I try to run it, tell it to "run on server", and it goes to http://localhost:8080/TomcatDebug/ but gives a 404. I even try to add index.html but it still gives a 404.
This is about as basic as it can possibly get so what did I do wrong?
Continuing to try and figure this out I stop the server, change the server setting to "use tomcat installation", but still get a 404 in the same way when I restart. I tried changing my module context path and still 404.
I'm completely stumped. I believe I followed all the wizards as basically as possible. Where did I go wrong?
Thanks for taking a look.
I haven't run tomcat through eclipse in a while, so can't answer that aspect of the question. But, to get at the heart of what you're trying to do (debug a webapp in eclipse through tomcat), you shouldn't necessarily need to. This may serve you instead:
EDIT: Eh, look here for instructions ("Debugging" section). The below is how I did it (JUNO and TC 7) and has an annoying quirk in point #1.
edit the startup.sh (assuming *NIX/OS X) - the last line will probably be
exec "$PRGDIR"/"$EXECUTABLE" start "$#"
change this to
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$#"
to activate debugging. (there are other ways to do this that may be better - i think tomcat/the VM may pause for listeners before proceeding, so when you aren't debugging this is not ideal)
Create a Debug Configuration in eclipse, under the "Remote Java Application" set. Default port should be fine, and presumably host. Choose your project.
Add sources of relevance to your debugging in the Source tab.
Start server and run your new debug configuration. App should stop at breakpoints you've set.
Right Click your index.html Run As -> Run On Server you will see Tomcat will automatically run the page.

Eclipse/PyDev/GAE: How do I add command line options to my Run As->PyDev Google App Run

I am using Eclipse/PyDev to develop a Google App Engine project called GAEServer. One of my common operations is to right click on the project and select Debug As->1 PyDev: Google App Run. Which kicks of a debug session for my application.
I would like to change the command line arguments executed when this command is invoked (to relocate where GAE local server looks for its database). This requires me to add arguments to the executed command.
If I select from the main menu: Run->Debug Configurations... there is an expandable item called PyDev Google App Run which contains a list of items:
PyDev Google App Run
GAEServer GAEServer
GAEServer GAEServer (1)
GAEServer GAEServer (2)
...
At the moment I have 19 of these which is a little surprising. If I select the first one then there is a tab where you appear to be able to add arguments (x)= Arguments but if I edit this and try to debug as again, it does not invoke GAE with the additional options, instead it creates another GAEServer GAEServer (n) with the default settings.
It may be that I have set up my project in some odd way, that I'm not understanding how this is supposed to work or that I have uncovered a bug. Can anyone help me figure out which?
Thanks in advance
Jules
The run as will really create a new run configuration... Just erase the bunch of configurations you have, run it once and edit that one.
Later ( if you followed the suggestion on http://pydev.org/manual_101_run.html ), you should be able to Ctrl+F11 to rerun the last launch done (or choose it from the menu: run > run history > previous launches: can be accessed through Alt+R, T, number of config).

Build and run Disabled in xcode

There are some applications which shows Build and run icon disabled which stops me from running the application.It does not happen to all applications but on a few . It mainly occurs to me in facebook applications and a few more applications.Can anybody have an idea what could be the problem ? I have tried everything from changing the build settings etc. but it does not work.
Need to fix the executable, it happens after renaming project.
Product > Scheme > Edit scheme..
Select
Run > Info
Set Executable is your app name, if selected None.
Try this, It's work for me.
Follow below steps to unable Build and Run in xcode
1) Go to
Product => Scheme => Edit scheme.
2) Select Run option and select info
3) In Executable if option is selected to None then change it to your app name
Hope this is help for some one.
That project appears to be the Sparrow audio project. It's not a stand-alone project you can run; it's a library, you need to be using it in another project to have anything to actually run.
The sparrow project includes a sample app called Scaffold which demonstrates the use of Sparrow. More info:
http://www.sparrow-framework.org/help/gettingstarted/
Also see:
http://www.sparrow-framework.org/help/documentation/
Note that you can still 'build'; it's just 'build and run' that can't be clicked.
I think those may be frameworks,static libraries. So the build and run option is disabled.
I think you might be creating plugin or frameworks or libraries (not an Application).
So the "Build & Run" icon is DISABLED.(as answered by Chandan Shetty SP)
In order to enable the icon you need to specify the Application which use this plugin or framework or library whatever you are building.
To specify such application:
Rt. Click on "Executables" (in Xcode's Groups and Files panel)
Select Add > New Custom Executable
Then specify the name of application (just for display purpose) and specify the path of the application.
Go to the Project menu in the menubar and change the Active Target to the target of the actual app.

How can I bind a specific key to different launch configurations in Eclipse?

I have several launch configurations for the code I work on.
One configuration (#1) means "run the unit tests for the file in the frontmost editor (i.e. selected resource)". I would really like to be able to always make this be bound to a key.
Another configuration (#2) means "run the server that I am working on (in the frontmost project) so I can test it interactively".
Yet another (#3) means "run some automated acceptance tests against the server".
I always want to have #1 close at hand, easy to run from a single keystroke. Plus, I want to be able to run #2, watch it start up in a console, and when it's ready (since it's not entirely trivial to automate this) hit the key for #3.
This is possibly similar to the question for binding a key to a specific build configuration, but the answers there look very specific to builds, and as I'm using PyDev, I don't have a "build" step at all.
Also, given that I'm using PyDev, an answer in the form of a pyedit_* script would be appreciated just as much as a "native" answer for eclipse.
Maybe Eclipse Runner plugin could make it easier for someone to handle launch configurations. It doesn't allow to assign key binding to launch configurations currently but I opened a feature request Key bindings for launch configurations
Not to a specific launch Configuration , but you can bind a key to run Last run Configuration ,
Windows->preferences->General->Keys->Run last launched external Tool
You can do the following (for #2 and #3), after having those run configurations created:
Go to Run > Run Configuration > Select the run configuration you want > Common > Display in Favorites Menu > Check Run/Debug. This will make it always appear as the first on the menu.
This will make it appear in the menu in Run > History and Run > Debug History, then, you can access it through Alt+R, T, 1 (and 2 and 3) to run your configurations or Alt+R, H, 1 (and 2 and 3) to debug.
And for #1, as Piotr Dobrogost said, you can just use Ctrl+F9 in the current editor and choose which test-cases you want to run (if you select a unit-test -- usually with Ctrl+Shift+Up or Ctrl+Shift+Down -- it'll be pre-selected for you) -- then, if you configured to always relaunch the last launch, as explained in http://www.pydev.org/manual_101_run.html, you can use Ctrl+F11 to relaunch the last launch.