Skip to content

Package Project

To be able to distribute your program and the INFINITY.JS runtime, you will need to at least include the folders with the runtime executables for the platforms you want to support, the resources and redist folders and your project folder (example-1 in our case):

+ bin
  + example-1
    + js
  + resources
  + linux-x64
  + win-x64
+ redist
- LICENSE
- THIRD-PARTY-NOTICES.md

Of course, you could omit the folder with the platform runtime you don't need (win-x64 for Windows x64, linux-x64 for Linux x64). The redist folder should be included for Windows, because it contains the Visual C++ Redistributable (vc_redist.x64.exe) that you might need to install before being able to run the INFINITY.JS runtime. You will only need the js folder from your project as well as any assets you might have added (images, etc.). The logs and temp folders next to the platform folders are created by the runtime.

You might want to remove the infinity.ini files from your platform runtime folders, if they contain settings for your development system only. Ship the infinity.default.ini file instead and copy it to infinity.ini on the target system.

To make it easier to start your program using the INFINITY.JS runtime, you could add a batch file or shell script next to the bin folder that executes the runtime with your main javascript file. The command line syntax for running your program in the INFINITY.JS runtime is infinity [options] [scriptfile]. A relative script path is resolved against the folder of the executable (not against the current directory), e.g. for Linux:

bin/linux-x64/infinity -console ../example-1/js/main.js

The script file is the first command line parameter that ends in .js. You can add additional command line options, e.g. -console to enable console output (without it, the output only goes to the log file in the logs folder). Run infinity -help to list all options.

Running as a Service

Windows: Use infinity.service.exe from the win-x64 folder and install it as a Windows service with infinity.service.exe /install (remove it with /uninstall, both as administrator). The service ignores command line arguments and always runs ../app/js/main.js relative to the win-x64 folder, so put your project into a folder called app next to it:

+ bin
  + app
    + js
      - main.js
  + resources
  + win-x64
    - infinity.service.exe
    - infinity.service.ini

Copy infinity.service.default.ini to infinity.service.ini to set the service name, display name, start type and dependencies, as well as the log file and MIME type settings.

Linux: Run INFINITY.JS as a systemd unit. The release archive contains a template in bin/linux-x64/infinity.service. A unit file looks like this:

[Unit]
Description=My INFINITY.JS application
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/myapp/linux-x64
ExecStart=/opt/myapp/linux-x64/infinity ../app/js/main.js
Restart=always
RestartSec=5
User=myapp

[Install]
WantedBy=multi-user.target

Save it as /etc/systemd/system/myapp.service and enable it with sudo systemctl daemon-reload && sudo systemctl enable --now myapp. systemd doesn't use a shell to start the program, so don't use redirections (like > /dev/null) in ExecStart. Use infinity.terminate(exitCode) with an exit code other than 0 if systemd should treat the end of your program as a failure (e.g. for Restart=on-failure).

In both cases, check infinity.terminated in the main loop of your program, so that it stops cleanly when the service is stopped.

Now that you've set up your development environment and know how to build and package your application, there are a few basic concepts of the INFINITY.JS engine you need to be aware of: Concepts