有些时候程序开启了http服务,监听了某个端口。
然后关闭终端或者CTRL+C退出之后,进程没有被杀掉,端口还在监听,导致下次启动的时候报错。
这里就记录下来,查看进程监听的端口,以及杀死进程
代码全部来源于官方教程
新建目录,把所有文件放在同一目录下
在该目录下执行命令
$ echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
$ echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -w kern.maxfiles=65536
$ sudo sysctl -w kern.maxfilesperproc=65536
$ ulimit -n 65536
interface User { | |
username: string; | |
roles: string[]; | |
} | |
interface Role { | |
name: string; | |
desc: string; | |
permission: Permission[]; | |
} |
package main | |
import ( | |
"net/http" | |
"log" | |
"io/ioutil" | |
"encoding/json" | |
"bytes" | |
"strings" | |
) |
构建一个可用的内存缓存.
const { spawn, exec } = require('child_process'); | |
const COMMAND = Symbol('command'); | |
class Shell { | |
constructor(command) { | |
this[COMMAND] = [command]; | |
} | |
} | |
const run = new Proxy( |
class Node { | |
constructor(prev, value, next) { | |
this.prev = prev; | |
this.next = next; | |
this.value = value; | |
} | |
} | |
const CURRENT_INDEX = Symbol('current index in cycle'); | |
const ROUND_INDEX = Symbol('how many round in cycle'); |
package pool | |
import "time" | |
type Event struct { | |
Time time.Time | |
Name string | |
Data interface{} | |
Id string | |
} |
/** | |
* Generate a New status | |
* @param code | |
* @param message | |
* @constructor | |
*/ | |
function Status(code, message) { | |
this.code = code; | |
this.message = message; | |
} |