Node
A NodeJS program is defined like a browser-based Gren program, except that there is more flexibility regarding how it is initialized.
You can initialize any number of subsystems, like FileSystem
or Terminal
, before
initializing your own program with the results of those initializations.
As part of initializing a subsystem, you usually also get access to a value that permits you to contact said subsystem. Be careful what code you give these permissions to.
Program
The definition of a Gren program that runs on NodeJS.
The required functions that define a program.
Define a program with access to long-lived state and the ability to respond to messages and listen to subscriptions. If you want to define a simple and short-lived program, chances are you're looking for defineSimpleProgram instead.
This lets the runtime know that you're done initializing other subsystems, and that your program is ready to start.
Simple Program
A program that executes a single task and then exits.
Define a simple program that doesn't require long-lived state or the ability to respond to messages or subscriptions. Ideal for simple and short-lived programs.
When defining a program with defineSimpleProgram, use this function to define the final command to execute.
Environment information
Contains information about the environment your application was initiated in.
platform
andcpuArchitecture
tells you something about the operating system and machine your application is running on.args
is anArray
of the arguments passed to your application.stdout
,stderr
andstdin
are streams you can use to communicate with the outside world. Take a closer look at theStream
module for more information.
The platform, or operating system, that your application is running on.
The CPU architecture your application is running on.
Get a Dict
of environment variables.
Exit
Terminate the program immediatly. It will not wait for tasks like http calls or file system writes, so only use this if you've reached a state where it makes no sense to continue.
Terminate the program immediatly. It will not wait for tasks like http calls or file system writes, so only use this if you've reached a state where it makes no sense to continue.
The exit code can be read by other processes on your system. Any value other than 0 is considered an error.
Set the error code that the program will return once it finishes.
Note: This will not terminate your program, so things like http calls or writes to the filesystem will be allowed to complete. However, the program will only exit once there are no ongoing tasks.