Infrastracture behind a web UI for GNU Octave, the libre alternative to MATLAB.
Deploy this app to Linode with a free $100 credit!
This repository contains the full stack of code to run Octave Online Server, the infrastructure that powers Octave Online.
There are three separate components of Octave Online Server:
Communication: The Client and Front Server communicate primarily with WebSockets via socket.io; the Front Server and Back Server communicate primarily with Redis PubSub. User account information is stored in MongoDB and is accessed primarily from the Front Server. User files are stored in Git on the Server and are accessed primarily from the Back Server.
Scaling: Front Servers and Back Servers can be scaled independently (in general, you need more Back Servers than Front Servers). It is also possible to run both the Front Server and the Back Server on the same computer.
Languages: All code is written with JavaScript technologies, although for historical reasons, the three components use different flavors of JavaScript. The Client uses ES5; the Front Server uses TypeScript; and the Back Server uses ES6.
Read containers/README.md for details on running a containerized version of all of Octave Online Server for use with trusted users. This is the fastest way to get off the ground.
Note: Octave Online Server has a lot of moving parts. It is recommended that you feel comfortable with basic system administration before attempting an installation.
For more details on operating each of the three components, see the respective README files:
There are also a few more directories for other components:
Every subdirectory of the top-level Octave Online Server directory has a README file that explains what the contents of the directory is for.
[Required] Operating System: Octave Online Server is built and tested exclusively on GNU/Linux. It is recommended that you use CentOS 8, although other modern distributions should work also. Most of Octave Online Server should work on macOS, but this has not been tested.
[Required] Node.js: Octave Online Server is built and tested with Node.js LTS version 10. This is the default version on CentOS 8.
# Install Node.js 10.x LTS on CentOS 8:
$ sudo yum install nodejs
[Required] Redis: Install and run a local Redis instance. Enable expiration events in redis.conf
:
$ sudo yum install redis
$ sudo emacs redis.conf
# Search for "notify-keyspace-events"
# Set the value to "Ex"
Although it is possible to use a third-party hosted Redis instance, this is not recommended because Redis latency is amplified due to its central role in the Octave Online Server architecture.
[Recommended] Git Server: In order to persist user files between sessions, you need to set up a Git file server. It boils down to a server, which could be the current server, with a low-privileged user usually named "git". For more information, see Git on the Server. Also see back-filesystem/README.md for instructions on how to configure a Git file server for Octave Online Server.
[Recommended] MongoDB: Install and run a MongoDB instance. Unlike Redis, MongoDB is not as central of a piece in the infrastructure, so it is possible to use a remotely hosted MongoDB if you do not want to host it locally. My experience is that it takes some time to correctly configure a fast and secure MongoDB installation. Keep in mind that MongoDB will contain personally identifiable information for user accounts.
[Recommended] Email SaaS: If you want Octave Online Server to be able to send transactional emails, such as for email-based login, you need a Mailgun or Postmark account. Mailgun has a free tier that should cover most experimental and low-traffic usage.
[Recommended] ReCAPTCHA: Certain actions, such as when email is sent, require a CAPTCHA to prevent abuse. You should register for a ReCAPTCHA v2 Checkbox and put your credentials into your config.hjson file.
[Optional] Google Analytics: For aggregated statistics about traffic to your site, you can enable Google Analytics integration.
[Optional] Nginx: For better performance with serving static files and easier HTTPS setup, I recommend installing and configuring Nginx. However, this is not an essential piece, and it can be done after the rest of the infrastructure is up and running.
Read config_defaults.hjson
to learn more about the array of settings available for Octave Online Server. When ready, copy config.sample.hjson
into config.hjson
, and fill in the required details. Your own config.hjson
is ignored by source control.
In each of the five directories containing Node.js projects, go in and run npm install
:
$ (cd shared && npm install)
$ (cd back-filesystem && npm install)
$ (cd back-master && npm install)
$ (cd front && npm install)
$ (cd client && npm install)
You also need to install the Bower (client-side) dependencies for the client project:
$ (cd client && npm run bower install)
Finally, build the client and front server projects (the back server runs without needing to be built):
$ (cd client && npm run grunt)
$ (cd front && npm run grunt)
Octave Online Server requires a special version of GNU Octave, which needs to be built. This is a required step. For more information, see back-master/README.md.
To run the code manually, just open up two terminals and run each of the following two commands:
$ (cd back-master && DEBUG=* node app.js)
$ (cd front && node app.js)
To run the code as a service, you can install the systemd service provided in this repository and enable the code to be automatically run at startup; see entrypoint/oo.service and make install-selinux-bin
.
Tip: When debugging, you can modify your hosts file (on macOS, /private/etc/hosts) to create a stable URL that you can add to your Google developer console to allow Google services to work.
You are welcome to send pull requests for consideration for addition to Octave Online Server. Pull requests are not guaranteed to be accepted; if in doubt, you should open an issue to discuss your idea before spending time writing your pull request.
Like many projects distributed with copyleft licenses such as AGPL, contributors to Octave Online Server must sign a Contributor License Agreement (CLA). The terms of the Octave Online CLA are taken from The Apache Software Foundation CLA. Having a CLA in place enables Octave Online Server to be distributed with alternate licensing schemes, including commercial licenses that help keep the project afloat.
If in doubt on style, follow the convention of the file you are editing.
Wrapping and Indentation: Use tab indentation, unless in a file format such as .yml that requires space indentation. There is no limit on line length. This gives you full control to configure your editor to your desired width and tab size.
Naming: In general, use camelCase for variable names and MACRO_CASE for constants. Prefix private members with an underscore (_
).
Quotes: Use double-quoted strings, unless you are in a context where you need a different quotation style, such as backtick strings in JavaScript.
Internationalization (i18n/l10n): If possible, all new UI strings should be extracted into en.yaml so that they can be translated. For more details, see front/locales/README.md.
Upstream/Downstream: Throughout the code, there are comments and function names indicating "upstream" and "downstream". "Upstream", or "U", means toward the Octave process, away from the client. "Downstream", or "D", means toward the client, away from the Octave process. So, for example, a message sent from the back server to the front server is considered downstream, and a message sent from the back server to the Octave process is considered upstream.
ECMAScript Versions: JavaScript code in the client project should conform to the ECMAScript 5 standard, in order to have broad browser support. JavaScript in all other projects can use the latest ECMAScript standard supported by Node.js 6.x LTS. By design, all JavaScript code in Octave Online Server server should be able to be run natively without transcompilation to a different ECMAScript version.
The eslint tool will catch most style and compatibility issues in JavaScript files. Execute npm run lint
in the top-level directory to check for errors. If your code does not pass eslint, you will also trigger a Travis failure on GitHub.
Due to the complexity of Octave Online Server, there is not currently an automated test suite. As a contributor, you are expected to perform some manual testing to ensure that your feature does not accidentally break something else in Octave Online Server.
Here are some critical user journeys that test a fairly wide cross-section of the code base. Please make sure that all of these journeys continue working after your change.
.octaverc
with the following content:
rcx = 5;
exit
command, then click the reconnect linkrcx
exists and has value 5sombrero()
and fplot(@sin, [-pi pi])
, and ensure they appear as expectedimshow(imread("mandrill.png"))
; you should see the full-color image appear in the console output window (there is a surprisingly large amount of code that is needed to make this happen)clc
; it should clear all output from the console windowdoc fplot
; it should produce a working linkchar(randi(256, 1000, 1)' .- 1)
; it should print a nonsense string with a lot of replacement charactersO = urlread("http://example.com")
; it should finish without error and print the HTML content of that pageO = urlread("https://example.com")
; it should print the same HTML as the previous line (http vs https)O = urlread("http://cnn.com")
; it should print an error saying that the domain is not in the whitelist (unless you added that domain to your custom whitelist)ping
; you should see a response like "Ping time: 75ms"pause; disp("done")
; you should see a message "press enter to continue". Press enter, and then you should see "done" printed out to the consolegf
; you should see a message "Run 'pkg load communications' to use 'gf'"pkg load communications
and then help gf
; you should get a help pageaudioread("dummy.wav")
; you should get an error that the file does not exist (but you should NOT get an error that says libsndfile was not installed)fork
; you should see a message "error: 'fork' undefined near line 1, column 1"instructor
field in mongodb; for example, "test-course"
enroll("test-course")
and follow the onscreen instructionsenroll("default")
and follow the onscreen instructionsx = 5
and press Enter, followed by x
and Enter, to ensure that the variable is set correctlyx
and Enter; the variable should still have the value 5exit
; it should say "Octave Exited. Message: Shell Exited", and you should get a link that says "Click Here to Reconnect"x = 99
x
is still 99
config.redis.expire.timeout
milliseconds to ellapse, then open up a new tab for that user; it should be a new session. Check that x
is no longer set to 99
edit demo_fn.m
; it should create a new file with that name and open it in the editorfunction [o] = demo_fn(x)
o = x*2;
endfunction
ans = 6
in the console output windowdemo_fn.m
, using the "Create empty file" button. You should not be able to create a file with that name since it already existsfpl
into the prompt box, then hit TAB. You should get a menu of auto-completions like fplot
x=1
then x=2
then x=3
. Press the up arrow. You should be able to scroll through your command historycd dir1
; you should now be changed into that directory and there should be a small window reminding you in the top left of the console output windowA = rand(500); save A.mat; load A.mat
A = rand(5000); save A.mat; load A.mat
plot(rand(100));
plot(rand(300));
pause(12)
x = 0; while(true), x += 1, end
x
should get to somewhere between 1500 and 2000 before being paused for payloadx
should climb by approximately the same amountTip: A community member like you could implement an automated end-to-end test suite. If this is your area of expertise, please open an issue and engage!
Octave Online Server is licensed under the GNU Affero General Public License.
Octave Online Server is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Octave Online Server is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
A copy of the license can be found in COPYING.
Note: You may contact webmaster@octave-online.net to inquire about other options for licensing Octave Online Server.
Please login to review this project.
No reviews for this project yet.
Comments (0)
Please login to join the discussion on this project.