Advertisement
robertbira

Italian Translation Report: Node.js [Part 37 - 1129 words]

Sep 22nd, 2018
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. Example: sending a server object
  2. The argument can be used, for instance, to pass the handle of a TCP server object to the child process as illustrated in the example below:
  3. Open up the server object and send the handle.
  4. The child would then receive the server object as:
  5. Once the server is now shared between the parent and child, some connections can be handled by the parent and some by the child.
  6. While the example above uses a server created using the module, module servers use exactly the same workflow with the exceptions of listening on a event instead of and using instead of
  7. This is, however, currently only supported on UNIX platforms.
  8. Example: sending a socket object
  9. Similarly, the argument can be used to pass the handle of a socket to the child process.
  10. The example below spawns two children that each handle connections with "normal" or "special" priority:
  11. Open up the server and send sockets to child.
  12. Use to prevent the sockets from being read before they are sent to the child process.
  13. If this is special priority
  14. This is normal priority
  15. The would receive the socket handle as the second argument passed to the event callback function:
  16. Check that the client socket exists.
  17. It is possible for the socket to be closed between the time it is sent and the time it is received in the child process.
  18. Once a socket has been passed to a child, the parent is no longer capable of tracking when the socket is destroyed.
  19. To indicate this, the property becomes
  20. It is recommended not to use when this occurs.
  21. It is also recommended that any handlers in the child process verify that exists, as the connection may have been closed during the time it takes to send the connection to the child.
  22. A that represents the child process's
  23. If the child was spawned with set to anything other than then this will be
  24. is an alias for
  25. Both properties will refer to the same value.
  26. Note that if a child process waits to read all of its input, the child will not continue until this stream has been closed via
  27. A sparse array of pipes to the child process, corresponding with positions in the option passed to that have been set to the value
  28. Note that and are also available as and respectively.
  29. In the following example, only the child's fd is configured as a pipe, so only the parent's is a stream, all other values in the array are
  30. Use parent's for child
  31. Pipe child's to parent
  32. Direct child's to a file
  33. The option specifies the largest number of bytes allowed on or
  34. If this value is exceeded, then the child process is terminated.
  35. This impacts output that includes multibyte character encodings such as UTF-8 or UTF-16.
  36. For instance, will send 13 UTF-8 encoded bytes to although there are only 4 characters.
  37. Shell Requirements
  38. The shell should understand the switch on UNIX or on Windows.
  39. On Windows, command line parsing should be compatible with
  40. Default Windows Shell
  41. Although Microsoft specifies must contain the path to in the root environment, child processes are not always subject to the same requirement.
  42. Thus, in functions where a shell can be spawned, is used as a fallback if is unavailable.
  43. Node.js comes with a variety of CLI options.
  44. These options expose built-in debugging, multiple ways to execute scripts, and other helpful runtime options.
  45. To view this documentation as a manual page in a terminal, run
  46. Synopsis
  47. Execute without arguments to start the
  48. For more info about, please see the debugger documentation.
  49. Options
  50. Alias for, analogous to the use of - in other command line utilities, meaning that the script will be read from, and the rest of the options are passed to that script.
  51. Indicate the end of node options. Pass the rest of the arguments to the script. If no script filename or eval/print script is supplied prior to this, then the next argument will be used as a script filename.
  52. Aborting instead of exiting causes a core file to be generated for post-mortem analysis using a debugger (such as and)
  53. If this flag is passed, the behavior can still be set to not abort through (and through usage of the module that uses it).
  54. Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with
  55. Enable experimental ES module support and caching modules.
  56. Enable experimental top-level keyword support in REPL.
  57. Enable experimental ES Module support in the module.
  58. Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) (Same requirements as)
  59. Specify ICU data load path. (Overrides)
  60. Activate inspector on and break at start of user script.
  61. Default is
  62. Set the to be used when the inspector is activated.
  63. Useful when activating the inspector by sending the signal.
  64. V8 inspector integration allows tools such as Chrome DevTools and IDEs to debug and profile Node.js instances. The tools attach to Node.js instances via a tcp port and communicate using the Chrome DevTools Protocol.
  65. This option is a no-op. It is kept for compatibility.
  66. Silence deprecation warnings.
  67. Disables runtime checks for
  68. These will still be enabled dynamically when is enabled.
  69. Silence all process warnings (including deprecations).
  70. Load an OpenSSL configuration file on startup. Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with
  71. Emit pending deprecation warnings.
  72. Pending deprecations are generally identical to a runtime deprecation with the notable exception that they are turned off by default and will not be emitted unless either the command line flag, or the environment variable, is set. Pending deprecations are used to provide a kind of selective "early warning" mechanism that developers may leverage to detect deprecated API usage.
  73. Instructs the module loader to preserve symbolic links when resolving and caching modules.
  74. By default, when Node.js loads a module from a path that is symbolically linked to a different on-disk location, Node.js will dereference the link and use the actual on-disk "real path" of the module as both an identifier and as a root path to locate other dependency modules. In most cases, this default behavior is acceptable. However, when using symbolically linked peer dependencies, as illustrated in the example below, the default behavior causes an exception to be thrown if attempts to require as a peer dependency:
  75. The command line flag instructs Node.js to use the symlink path for modules as opposed to the real path, allowing symbolically linked peer dependencies to be found.
  76. Note, however, that using can have other side effects.
  77. Specifically, symbolically linked modules can fail to load if those are linked from more than one location in the dependency tree (Node.js would see those as two separate modules and would attempt to load the module multiple times, causing an exception to be thrown).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement