Jump to: navigation, search

Difference between revisions of "Orion/Node/Getting started"

< Orion‎ | Node
(Features)
Line 22: Line 22:
 
=== Installing with npm ===
 
=== Installing with npm ===
 
To install Orion with the Node Package Manager (npm), simply run the following command from the shell:
 
To install Orion with the Node Package Manager (npm), simply run the following command from the shell:
# Run this command from a shell:<br><code> npm install orion</code><p>This should install Orionode into a node_modules subdirectory of your working directory.
+
# Run this command from a shell:<br><code> npm install orion</code><br>This should install Orionode into a node_modules subdirectory of your working directory.
 
#* If you're not interested in developing the Orionode server, add the <code>--production</code> flag for a slightly smaller download.
 
#* If you're not interested in developing the Orionode server, add the <code>--production</code> flag for a slightly smaller download.
  

Revision as of 14:37, 8 February 2013

Orion provides a minimal, single-user server deployment of Orion written in JavaScript that runs on Node.js. This implementation of Orion supports developing your own Node applications with Orion's editing environment.

Features

The JavaScript Orion server implementation is still very early access. There are many rough edges and missing features compared to the full Java-based Orion server. The JavaScript-based Orion server currently supports:

  • Basic Navigator operations (Create file/folder, delete file/folder, copy/move/rename a file)
  • Basic Editor operations (Edit file, save file, ETags)
  • Plugin operations (Install/uninstall plugins)
  • Shell command for launching a node app (type help node in the Shell page to find out more)
  • Shell command for supporting npm. (works the same as the usual npm console command).
  • Gzip on server traffic to reduce download times
  • Concatenation and minification of pages (requires a manual step)
  • Client caching for static HTML+JS content (cache time: 2 hours)

Requirements

  • Node.js and npm.
  • A modern web browser with Web Socket support (for example: Firefox 15, Chrome 22, Internet Explorer 10, Safari 6).

Getting Orionode and starting it

You can obtain Orionode through npm (the easiest way) or by checking out its source repo and running it. Checking out the source is mainly of interest to developers wishing to work on or extend the Orion node server. For details on this approach see the Orion developer wiki page.

Installing with npm

To install Orion with the Node Package Manager (npm), simply run the following command from the shell:

  1. Run this command from a shell:
    npm install orion
    This should install Orionode into a node_modules subdirectory of your working directory.
    • If you're not interested in developing the Orionode server, add the --production flag for a slightly smaller download.

Starting and stopping the server

  1. Launch Orion by running:
    npm start orion
    • If you need to pass command line arguments to the server, run the server.js file directly:
      node node_modules/orion/server.js [arguments]
  2. Go to http://localhost:8081 (or whatever port you provided in the server arguments) in your web browser to start using Orionode.
  3. Stop the server by sending a kill signal from the console (typically Ctrl+C)

Other recommended steps

These are not strictly necessary to run the server, but recommended anyway.

Password
  1. Create a one-line "password.txt" file containing a secret password.
  2. Launch the Orionode server with the -password password.txt argument.

You can also provide a password in an orion.conf file by including a line like:
pwd=mysecretpassword

Making sure Orion can launch npm

Orion on Node lets you use npm commands in the Orion shell to manage the dependencies of a project you're writing. To do this, the server makes a guess about the path where the npm internals (specifically, npm-cli.js) are located on your computer. If you installed a recent version of Node.js, npm should be installed automatically and the guess should work. If you installed npm separately, this guess may be wrong. If you see an error message when launching the server or when you try to run npm commands in the Orion shell, it means the server failed to guess where npm lives, so you have to specify the path to npm-cli.js yourself:

  1. Find out where npm lives on your computer (npm must be in your PATH environment variable for this to work). From a command shell, run:
    • On Windows: where npm
    • On Mac OS/Linux: which npm
    • The returned path will be a shell script (or a symbolic link to a script) that launches npm-cli.js. The path to npm-cli.js is what we need. Open up the script in a text editor, and copy the path of npm-cli.js.
  2. In the server directory, open the orion.conf file. You'll find a npm_path option (by default its value is empty).
  3. Set the value of npm_path option equal to the path to npm-cli.js.
    • You can provide the path as an absolute path, or a path relative to your node executable.
  4. Start or restart the server. If you do not see any "npm" errors printed to the console, your npm path is set properly.

Server command line arguments

All these arguments are optional.

-p or -port
The port that the Orion server will listen on. Defaults to 8081.
-pwd or -password
Path to a file containing a password. If provided, Orionode will enforce HTTP Basic Authentication with the password (the auth 'User' field is ignored -- Orionode only verifies the password). Use caution: if you don't provide a password file, no authentication is used (so anyone can access your Orionode server and read and write your files!).
-w or -workspace
The target directory for reading and writing files. Will be created if it doesn't exist. Defaults to a subdirectory named .workspace in the server directory.
-dev
Starts the server in development mode. In this mode, some client-side code is not cached by the browser, to ease development.
-log
Logs each request served to standard output.

Developing a node.js application

Now in the browser you can start to develop your node.js applications. Orionode uses largely the UI you're accustomed to from Orion. (Refer to Orion user guide for basic instructions). Please note that the Sites and Git pages are not available in Orionode. Here is a typical workflow:

  1. Use the Navigator and Edit pages to create and edit your folders and node applications.
  2. Go to the Shell page.
  3. cd to the folder where your application lives.
  4. Use npm install to install your dependency packages if needed. You can use basically all the npm arguments here.
  5. Use node start yourApp.js to start your application.
  6. Use node list to monitor any long-running applications you've started.
  7. Use node stop [PID] to stop an application if you want to force it to stop.

Debugging a node.js application

You can use Orionode to debug your node.js application. If you have existing node.js applications, make sure the code is under a subfolder of the workspace (path provided by the -w option when you start Orionnode). This will give you easy access to your node.js apps from within Orionode. You can also create a new node.js application in your workspace.

  1. After Orionode starts, open the shell page and use help to see what commands are available.
  2. cd to the folder where your application lives.
  3. Use node debug yourApp.js givenPort to start your app in debug mode. You can start multiple apps in debug mode by repeating this step.
  4. In the return value of the node debug command, you will see a "debugURL" string.
  5. Copy and paste the debug URL into a webkit browser (e.g., Chrome, Safari) and start debugging. The URL normally looks something like: http://yourOrionNodeServer:8900/debug?port=theGivenPort.


Other ways of using Orionode

You can use Orionode as a file server, to access your local files from http://www.orionhub.org/ (or any other Orion installation). All you need is Orionode and a publicly-accessible URL pointing to your local Orionode server.

  1. Visit this page on your Orionode server (the hostname will differ from this example) and copy its URL:http://yourOrionNodeServer:8081/plugins/fileClientPlugin.html
  2. Log in to Orionhub.
  3. Click the user menu in the top right-hand corner of the page, then click Settings.
  4. Select the Plugins category, click Install, paste in the URL, click Submit.
  5. Return to the Navigator page. Your Orionode files should appear as a new filesystem in the left-hand sidebar.

Security Concerns

No security is guaranteed or even implied at this moment. Always run Orionode with the -pwd flag to prevent unauthorized access to your files.

Known Issues

  • See the list of open bugs.
  • There is no way to provide standard input to a running Node.js app.
  • There is no source control integration yet. E.g.: Git support.