Execution
Running a Mélodium program is done with a simple call followed by the file containing the melodium run <FILE> program.
A direct call to melodium without a subcommand is equivalent to a call to melodium run.
If Mélodium is installed on the system by a standard means, the standalone .mel script files and .jeu programs are directly executable.
The following calls are equivalent:
$ melodium run my_program.jeu
$ melodium my_program.jeu
$ ./my_program.jeuEntry point selection
Mélodium programs have entry points.
By default if nothing is specified for the execution call, the main entry point is searched for and used.
If a program offers other entry points, these are accessible as subcommands.
In the case of a program having an entry point main as well as serve and connect, these three execution calls are valid:
$ ./my_program.jeu [main]
$ ./my_program.jeu serve
$ ./my_program.jeu connectArguments
The entry points of a program are simply Mélodium treatments, which can take parameters.
The parameters of a treatment used as an entry point are accessible as arguments for the command line, thus a serve entry point corresponding to a treatment having as parameters port: u16 and refresh: bool has equivalent arguments:
$ ./my_program.jeu serve --port 1234 --refresh trueSecret arguments
Parameters of type Secret<T> take a locator, such as env:MELODIUM_SECRET_NAME or file:PATH, never a value (see Secrets):
$ ./my_program.jeu --password file:/run/secrets/db_password--check-secrets resolves them before running, to fail right away when one cannot be resolved:
$ melodium run --check-secrets ./my_program.jeu --password env:MELODIUM_SECRET_DB_PASSWORDThreads
Tracks run in parallel, on one thread per core.
The MELODIUM_THREADS environment variable gives another number of threads, such as MELODIUM_THREADS=2.
Ending a run
A run ends once all its tracks are finished.
On Linux and macOS, SIGINT, SIGTERM, and SIGHUP ask the run to end: running tracks get 10 seconds to finish, and a second signal or the end of this delay stops them, along with the commands they launched. Mélodium then exits with code 128 plus the signal number, such as 130 for SIGINT.
On Windows, as a best effort, Ctrl+C and Ctrl+Break do the same. Closing the console, logging off, and shutting down also end the run, with only 2 seconds for running tracks, as Windows ends the process shortly after. Mélodium then exits with code 0xC000013A (STATUS_CONTROL_C_EXIT).
A program that cannot be launched, for example because a parameter is missing, exits with code 1.
Information about a program
To find out what commands a program has, the melodium info command lists the available entry points:
$ melodium info ./my_program.jeu
my_program
Version 0.1.0
Usage: my_program.jeu [COMMAND]
Commands:
main
serve
connectTo find out the specific arguments of a command, the --help argument can be used on it:
$ melodium ./my_program.jeu serve --help
Usage: serve [OPTIONS]
Options:
--port <port> u16
--refresh <bool> bool
-h, --help Print help