Giter VIP home page Giter VIP logo

nodedemo's Introduction

Some pure Node demo

autocomplete

use inquirer-search-list and inquirer to archive auto complete in cli.

crawler

Use crawler to get network content.

daemon

A simple daemon process

  1. Create a child process
  2. Create a new session in the child process (call system function setsid)
  3. Change the subprocess working directory (eg: "/" or "/usr/, etc.)
  4. Parent process termination

Using spawn to create a child process completes the first step above.

Setting options.detached to true causes the child process to continue running after the parent process exits, which is the second step.

Options.cwd specifies the current child process working directory.

If you do not set the default to inherit the current working directory, this is the third step.

Run daemon.unref() to exit the parent process, refer to options.stdio, which is the fourth step.

$ npm run demo:daemon

log will be write into ./daemon/stdout.log

fork_multiProcess_samePort

Start multiple processes on the same port

$ npm run demo:fork_multiProcess_samePort

only one process started, and other cpu's lengths process is error:

Use handle such as TCP socket, UDP and so on to solve this problem.

$ npm run demo:fork_multiProcess_samePort:true

fork_orphan

orphan process

$ worker process created, pid: 77815 ppid: 77814

it's fathers ppid is 1:

graphviz

use of node-graphviz

ipc_pipe

communication bewteen two process with pipe

$ npm run demo:ipc_pipe 
81160 81161
I am worker, PID:  81161

prettier

use yorkie/husky + lint-staged + prettier to format code after commit automatic

jsonfile

read and write json file

myPromise

Promise achieve based on promise/A+

single

single design pattern in node, by cache of module.

vm

usage of vm2

nodedemo's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.