Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.md | 2025-01-25 | 8.3 kB | |
rds-1.08.03.zip | 2025-01-25 | 6.1 MB | |
Totals: 2 Items | 6.2 MB | 0 |
Rust Development Studio - CGI
Purpose
A possibility to develop a software from any device and anywhere is frequently required. However the requirement to install the specific software for that on all devices can be complicated and not always possible. What about if a modern HTML 5 capable browser is sufficient to run the development environment? Certainly the major reason to write the software was the desire to convert a regular browser to IDE. So far, my goal was achieved and I do not care much about a computer I do development from. I can develop from my workstation using two 32" monitors and continue the development from Amazon Fire tablet when I am in the kitchen, or watching the latest TV show in the family room.
Architecture
The client part is quite obvious and utilizes HTML 5, CSS and JavaScript. But the server part resurrects the forgotten CGI technology which is perfectly suitable for using Rust. The terminal functionality is implemented using the websocket and it still relays on Java. So the project is a hybrid of Rust, HTML, CSS, JavaScript and Java.
Implementation
It's really compact with a footprint below 10 MB. All web requests are handled by one Rust CGI executable. The terminal is a websocket endpoint represented by one Java class. There is no a servlet.
Config
All below steps consider that TJWS is used as a web server and CGI provider. Any other server can be used with some modifications of the steps. You need to add to TJWS aliases.properties file lines reflecting the location of the CGI script like below:
from=/rustcgi;dir=~/projects/rust_util/src/rust/rustcgi
from=/cgires/resource;=~/projects/rust_util/src/rust/rustcgi/resource
Note that the resource directory has to be a sub-directory of the CGI script directory.
Specify aliases.properties in the TJWS starting command as:
-a aliases.properties
The /rustcgi mapping has to be a CGI aware when start TJWS using the command line argument below:
-c /rustcgi
Make sure that a directory, where rustcgi accessed from, contains the file .home with one line containing the user HOME directory or other directory where rustcgi will look for settings in the sub directory .rustcgi. For example:
/home/john
Another property has to be added to the starting starting TJWS command is:
-Dtjws.websocket.container=true
to assure that the websocket support will be enabled required for a terminal.
An acceptor with a channel for a non blocking IO is requiring for a correct websocket functionality. For example:
-acceptorImpl Acme.Serve.SelectorAcceptor
Currently the websocket uses the same host and port as the CGI server. If you plan to run a websocket
on different port or/and server, you need to specify its settings at line 384 in main.js
as bellow:
const port = 8443//location.port // 8443 for a brutal use different server
and uncomment the following line at 393
'ws'+sec+'://'+location.hostname+portExt+
Note that a server where websocket endpoint resides will be the server for all underline terminal commands. If websocket machine is different that CGI script machine, the HOME directory should be some network place accessible from both machines.
If you plan to use HOME directory different than provided by OS,
you need to specify it in a TJWS starting command as property HOME
:
-DHOME=/media/exhdd/RDS
Note: the home directory has to be in sync with in the .home file specified.
rds.sh
script with underline bee.7b
is a good example of the mentioned command options.
You are free to use any other web server capable to run CGI scripts. The same or other server implementing JSR 356 is required for a terminal support.
Ace Cloud editor
Rust Development Studio is loosely coupled with Ace (Ajax.org Cloud9) Editor.
RDS is coming bundled with some version of the Ace editor. You can always bundle it with any other version of the editor. Go to Ace and download a desired version and then copy it over the directory resource/ace.
What is the project?
RDS is a single user web application. However a user may want to handle several RDS projects in the scope of a single browser. The parameter project helps to separate projects and the corresponding settings data.
Packaging
Although you can configure the development studio yourself accordingly to a web server and other components, the packaging recommends TJWS as a web server. The following jars are required:
class-scanner.jar
javax.servlet-api-4.0.1.jar
javax.websocket-api-1.1.jar
rds.jar
webserver.jar
wskt.jar
Two underline OS executables' are written in Rust are:
rb
rustcgi
Any JVM from 8 to 23 can be used. HTTPS is supported and preferred.
The standard packaging includes all required RDS components. Just launch ./rds.sh
or .\rds.bat
and you can start using the RDS. The access URL stored in rds.url
.
Building rustcgi components
You need the rustc and javac for building RDS components. I use the RustBee scripting tool to simplify the build procedure.
However, you can use any other building tool (including Cargo) and own build scripts. If you decide to use the RustBee, you may need to build it too,
but only once.
For example, I wanted to build the RDS on Raspberry Pi. First, I installed rustc (you need the version 1.80 or better,
visit the site for an info how to install).
Next, I downloaded bee.jar
from sourceforge for a bootstrapping.
I downloaded the simple zip crate from github,
the simple time crate,
and
finally I checked out https://gitlab.com/tools6772135/rusthub/-/tree/master.
I switched to scr/rust/rustbee
and edited bee-rust.xml to specify the simple zip and the simple time repositories location.
I executed java -jar <dir where>/bee.jar
to build rb
. You can install it after the building by executing sudo ./rb install
,
or simply add the current directory to the PATH env.
You are ready to build rustcgi now. Switch to scr/rust/rustcgi
and execute rb
. Use
rb -Dopt=release
, for building a release version. Switch to directory src/java/rustcgi
to build rds.jar
.
Execute rb
. Copy src/java/lib/rds.jar
to the web server Java lib directory after. You can edit APP DEPLOY DROP
in
src/java/rustcgi/bee.7b
to specify the target directory and avoiding a manual copying. Restart the web server to get a new
websocket end point deployed.
The similar steps have to be performed on other platforms as Windows, MacOS, or BSD OS where no an installer provided yet. Assure only that a Windows executable has the extension .exe.
Working tips
You will see an empty page when first time pointed a browser to RDS URL. Select menu Settings or File/Projects/New. Navigate to a project directory and then save the settings. Reload the RDS web page. You can start now navigate over the project tree, open and edit files, build its components and so on.
If you do not have the project checked out yet, then you can check it out first, and then to set the project root in the settings. You can execute underline OS commands as mkdir, git clone, and others in the terminal window.
When you use Cargo to build a Rust project, make sure to set CARGO_TERM_COLOR
env variable to always
. It
is controlled also by term.color
of Cargo settings. For example:
[term]
color=always
Browser compatibly
RDS uses HTML 5 features and compatible with browsers supporting them. Compatibility was tested using the latest Firefox, Edge, and Amazon Silk browsers. More likely, other browsers will work too. If you encounter problems with any browser, then please report them to the author.
Known problems
- datalist seems isn't supported by the Silk browser, so an auto suggest won't work on Fire tablets
Reading about
- Some light on using technologies.