Skip to content

Running An Appjet App

dvbportal edited this page Dec 29, 2010 · 1 revision

Introduction

Appjet.jar contains everything to run server-side JavaScript applications. It is 100% write once - run everywhere code. Writing an Appjet app is the fastest method to get your code up and running - hosted on http://jgate.de - or on a server of your choice. For more information on Appjet see our blog.

Installation

Just put the jar file somewhere accessible from the command prompt.

Running an App

$ java -jar appjet.jar myapp.js

That's it! myapp.js should contain the same JavaScript code that you would use for an app hosted on jgate.de.

Complete Example

On a unix system with wget and Java installed: $ wget http://jgate.de/jar/appjet-1.0.4.jar $ wget http://jgate.de/jar/main.js $ java -jar appjet.jar Note that when you don't specify a file to run, it looks for "main.js"

Configuration

There are many configuration options. To see them all, run: $ java -jar appjet.jar --help Alternatively, you can create a properties file "appjet.properties" and point to it with --configFile=/path/to/appjet.properties. For example, to serve the app on port 9000, you can either pass "--port=9000" as a command-line argument, or put "port=9000" as a line in your appjet.properties file.

Here is an example appjet.properties file: port=80 appHome=/var/myAwesomeApp/src/ appjetHome=/appjet/

And here are all the available configuration options.

Property Description Default
port Port on which to serve the main app. 8080
dashboardPort Port on which to serve the "dashboard", which includes a shell and a debug log. (none)
previewPort Port on which to serve the app in "preview" mode. (none)
appHome Base directory to look for app's code files, such as main.js ./
appjetHome Directory to use for storing appjet support files, such as cron database, storage database, logs, etc. This directory will be created if it does not exist and must be writeable by appjet.jar. ./appjet
maxStorageBytes Quota for storage database. 104857600 (100MB)
ajstdlibHome Optional alternative directory to load built-in libraries from. Used by AppJet platform hackers to develop and debug built-in libraries. (use built-in libraries)
devMode Enables "developer mode". (Not for general use).
## Other Features

Database storage: Just like on app.jgate.de, you can import "storage" to store data persistently. Naturally, the database is persisted on disk between restarts of the server. You can also customize the storage quota with the --maxStorageBytes option.

Dashboard: If you specify a --dashboardPort option, appjet.jar will additionally listen on that port and serve an administrator's dashboard. (Be careful about making this port public to your users!)

Shell: You can access the command shell of the running app on the dashboard page.

Preview mode: Some AppJet apps rely on "preview mode" for certain operations. The configuration option --previewPort can be used to specify a port to serve the app in preview mode.

Editing code: appjet.jar will automatically notice changes to your javascript files, so you do not need to restart the server between file edits. Importing libraries: When you call import("lib-foo"), appjet.jar will look for a corresponding file in the appHome directory named "lib-foo.js". The appHome directory defaults to the working directory.

Logs: Apache-esque logs are stored in [appjetHome]/log/appserver/engine.access.[date].request.log.

License & Source Code

Disclaimer: The appjet.jar software is provided "as is", and you use it at your own risk. AppJet Inc. nor JGate is not responsible for anything bad that may happen.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Known Issues

None so far.

Feedback

Please use github or our contact page for feedback.

ChangeLog

1.0.4: Full REST support (GET, POST, PUT, DELETE) for servers and clients, link pointing to appjet.com changed to jgate.de.
1.0.3: Unicode support in source files.
1.0.2: Fixed an error in handling line endings.
1.0.1: Experimental support for Java 1.5 (not officially supported).
1.0: Initial release.