Functions for initializing and launching a yuno application.
Source: kernel/c/root-linux/src/entry_point.h,
kernel/c/root-linux/src/manage_services.h,
kernel/c/root-linux/src/yunetas_register.h
yuneta_setup()¶
Configures the yuneta runtime: persistent-attribute handlers,
command / stats parsers, authentication / authorization callbacks,
and memory allocator settings. Call once, before yuneta_entry_point().
int yuneta_setup(
const persistent_attrs_t *persistent_attrs,
json_function_fn command_parser,
json_function_fn stats_parser,
authorization_checker_fn authz_checker,
authentication_parser_fn authentication_parser,
size_t mem_max_block,
size_t mem_max_system_memory,
BOOL use_own_system_memory,
size_t mem_min_block,
size_t mem_superblock
);Parameters
| Key | Type | Description |
|---|---|---|
persistent_attrs | const persistent_attrs_t * | Custom persistent-attribute callbacks (NULL uses the built-in dbsimple backend). |
command_parser | json_function_fn | Custom command parser (NULL uses the built-in command_parser). |
stats_parser | json_function_fn | Custom stats parser (NULL uses the built-in stats_parser). |
authz_checker | authorization_checker_fn | Authorization checker (NULL uses the default C_AUTHZ monoclass). |
authentication_parser | authentication_parser_fn | Authentication parser (NULL uses the default C_AUTHZ monoclass). |
mem_max_block | size_t | Largest memory block size for the allocator. |
mem_max_system_memory | size_t | Maximum system memory the allocator can use. |
use_own_system_memory | BOOL | TRUE to use the custom memory allocator. |
mem_min_block | size_t | Smallest memory block size. |
mem_superblock | size_t | Super-block size. |
Returns
0 on success.
yuneta_entry_point()¶
Main entry point for a yuno application. Parses command-line arguments, loads configuration, sets up the environment, creates the yuno GObj tree, and runs the event loop.
int yuneta_entry_point(
int argc, char *argv[],
const char *APP_NAME,
const char *APP_VERSION,
const char *APP_SUPPORT,
const char *APP_DOC,
const char *APP_DATETIME,
const char *fixed_config,
const char *variable_config,
int (*register_yuno_and_more)(void),
void (*cleaning_fn)(void)
);Parameters
| Key | Type | Description |
|---|---|---|
argc | int | Argument count from main(). |
argv | char *[] | Argument vector from main(). |
APP_NAME | const char * | Application / yuno role name. |
APP_VERSION | const char * | Application version string. |
APP_SUPPORT | const char * | Support e-mail address. |
APP_DOC | const char * | Short documentation string. |
APP_DATETIME | const char * | Build date/time. |
fixed_config | const char * | Fixed configuration (JSON string). |
variable_config | const char * | Variable configuration (JSON string). |
register_yuno_and_more | int (*)(void) | Callback to register custom GClasses — executed after the environment is ready, but before yuno creation. It answers 0, or the sum of what its register_c_*() answer: a NEGATIVE answer (a gclass refused) stops the yuno -- an ERROR and exit(-1), before it runs, as a refused gclass of the core does (7.27.0+). |
cleaning_fn | void (*)(void) | Cleanup callback — executed after all resources are freed. |
Returns
Process exit code.
A gclass of the yuno that gclass_create() refuses stops
the yuno before it is created: “register_yuno_and_more() FAILED: a gclass of
the yuno was refused, the yuno exits”, an ERROR, and exit(-1) (7.27.0+). Up
to 7.26.9 the answer was added to the exit code and the yuno RAN: its services
failed later with “gclass NOT FOUND”. So register_yuno_and_more() hands
back what the registrations answer:
static int register_yuno_and_more(void)
{
int result = 0;
result += register_c_my_service(); // 0, or -1: refused, its ERROR logged
result += register_c_my_child();
return result; // < 0: the yuno exits
}Command-line options
Parsed here, so every yuno accepts them — the agent, the brokers, your own citizen yunos, the test binaries:
| Flag | Effect |
|---|---|
-S, --start | Run as a daemon: double fork plus the ydaemon watcher that relaunches the yuno on abnormal exit. Without it, the yuno runs in the foreground. |
-K, --stop | Stop the daemon of the same process name and exit. |
-f, --config-file=FILE | Load settings from a JSON config file, or from a JSON list of files merged in order. |
-p, --print-config | Print the final merged configuration and exit. |
-P, --print-verbose-config | Print the configuration with every default expanded, and exit. |
-r, --print-role | Print the yuno’s identity (role, name, version, tags…) and exit. |
-v, --version | Print the yuno’s version and exit. |
-V, --yuneta-version | Print the Yuneta runtime version and exit. |
-l, --verbose-log=N | Override handler_options of the stdout log handler — the bitmask selecting which fields each log line prints. Despite the name this has nothing to do with traces. |
-g, --global-trace=LEVEL | Enable a global trace level from start up. See below. |
set_auto_kill_time()¶
For testing: kills the yuno after a specified number of seconds. Only effective when the yuno is not running as a daemon.
void set_auto_kill_time(int seconds);Parameters
| Key | Type | Description |
|---|---|---|
seconds | int | Timeout in seconds after which the yuno is killed. |
Returns
This function does not return a value.
yuneta_is_daemon()¶
TRUE when the process was launched with --start, that is, it runs as a
daemon under the ydaemon watcher. FALSE for a plain foreground process: a
CLI utility, a test, a yuno run by hand. The signal policy depends on it (see
the SIGTERM case in c_yuno.c).
BOOL yuneta_is_daemon(void);Returns
TRUE under the watcher, FALSE in the foreground.
Example
if(!yuneta_is_daemon()) {
/* run by hand: print to the terminal as well */
gobj_log_add_handler("stdout", "stdout", LOG_OPT_ALL, 0);
}yuneta_json_config()¶
Returns the currently loaded JSON configuration object.
json_t *yuneta_json_config(void);Parameters
| Key | Type | Description |
|---|---|---|
- | - | This function does not take any parameters. |
Returns
Pointer to the configuration json_t object. The pointer is not owned
by the caller — do not modify or free it.
run_services()¶
Starts and plays services and the yuno in priority order.
Calls gobj_start() on the yuno, starts autostart services,
calls gobj_play() on the yuno if autoplay is enabled, and
plays autoplay services.
void run_services(void);Parameters
| Key | Type | Description |
|---|---|---|
- | - | This function does not take any parameters. |
Returns
This function does not return a value.
stop_services()¶
Pauses and stops services and the yuno in reverse priority order (priority 9 down to 0).
void stop_services(void);Parameters
| Key | Type | Description |
|---|---|---|
- | - | This function does not take any parameters. |
Returns
This function does not return a value.
yuno_shutdown()¶
Stops the yuno by marking it as shutting down and stopping the event loop.
void yuno_shutdown(void);Parameters
| Key | Type | Description |
|---|---|---|
- | - | This function does not take any parameters. |
Returns
This function does not return a value.
Notes
Calls
gobj_set_shutdown()followed byyev_loop_reset_running().
yunetas_register_c_core()¶
Registers all built-in runtime GClasses in one call. This is the centralized registration point invoked during yuno startup.
int yunetas_register_c_core(void);Parameters
| Key | Type | Description |
|---|---|---|
- | - | This function does not take any parameters. |
Returns
0 on success, -1 when a gclass was refused or when it is called a second
time (an ERROR logged in both cases).
Notes
Internally calls every
register_c_*()function listed in GClass Registration.yuneta_entry_point()calls it once, before the yuno’sregister_yuno_and_more(). A yuno never calls it: itsregister_yuno_and_more()registers its OWN gclasses only.A second call registers nothing and returns
-1with an ERROR that says why (“yunetas_register_c_core() called twice: ...”). Made fromregister_yuno_and_more(), that-1stops the yuno before it runs, as a refused gclass does. Up to 7.26.9 the second call returned-1with no log, and the only line was the entry point’s, naming no cause.
static int register_yuno_and_more(void)
{
int result = 0;
result += register_c_my_service(); // the yuno's own gclasses
// yunetas_register_c_core(); // NO: the entry point already did
return result;
}