Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cluster] Deprecate isMaster and setupMaster(), add isPrimary and setupPrimary() #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 48 additions & 11 deletions src/js/node/Cluster.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,19 @@ extern class Cluster extends EventEmitter<Cluster> {

/**
True if the process is a master.
This is determined by the process.env.NODE_UNIQUE_ID.
If process.env.NODE_UNIQUE_ID is undefined, then `isMaster` is true.
This is determined by the `process.env.NODE_UNIQUE_ID`.
If `process.env.NODE_UNIQUE_ID` is undefined, then `isMaster` is `true`.
**/
@:deprecated("Use `isPrimary` instead")
var isMaster(default, null):Bool;

/**
True if the process is a primary.
This is determined by the `process.env.NODE_UNIQUE_ID`.
If `process.env.NODE_UNIQUE_ID` is undefined, then `isPrimary` is `true`.
**/
var isPrimary(default, null):Bool;

/**
True if the process is not a master (it is the negation of `isMaster`).
**/
Expand All @@ -187,7 +195,24 @@ extern class Cluster extends EventEmitter<Cluster> {
`fork` calls `setupMaster` internally to establish the defaults, so to have any effect,
`setupMaster` must be called before any calls to `fork`
**/
function setupMaster(?settings:{?exec:String, ?args:Array<String>, ?silent:Bool}):Void;
@:deprecated("Use `setupPrimary()` instead")
function setupMaster(?settings:ClusterSettings):Void;

/**
`setupPrimary` is used to change the default `fork` behavior.

Once called, the `settings` will be present in `settings`.

Note that:
Only the first call to `setupPrimary` has any effect, subsequent calls are ignored

That because of the above, the only attribute of a worker that may be customized per-worker
is the `env` passed to `fork`

`fork` calls `setupPrimary` internally to establish the defaults, so to have any effect,
`setupPrimary` must be called before any calls to `fork`
**/
function setupPrimary(?settings:ClusterSettings):Void;

/**
Spawn a new worker process.
Expand Down Expand Up @@ -231,26 +256,32 @@ extern class Cluster extends EventEmitter<Cluster> {

typedef ClusterSettings = {
/**
list of string arguments passed to the node executable.
Default: process.execArgv
List of string arguments passed to the node executable.
Default: `process.execArgv`
**/
@:optional var execArgv(default, null):Array<String>;

/**
file path to worker file.
Default: process.argv[1]
File path to worker file.
Default: `process.argv[1]`
**/
@:optional var exec(default, null):String;

/**
string arguments passed to worker.
Default: process.argv.slice(2)
String arguments passed to worker.
Default: `process.argv.slice(2)`
**/
@:optional var args(default, null):Array<String>;

/**
whether or not to send output to parent's stdio.
Default: false
Current working directory of the worker process.
Default: `undefined` (inherits from parent process)
**/
@:optional var cwd(default, null):String;

/**
Whether or not to send output to parent's stdio.
Default: `false`
**/
@:optional var silent(default, null):Bool;

Expand All @@ -263,4 +294,10 @@ typedef ClusterSettings = {
Sets the group identity of the process.
**/
@:optional var gid(default, null):Int;

/**
Hide the forked processes console window that would normally be created on Windows systems.
Default: `false`
**/
@:optional var windowsHide(default, null):Bool;
}