Linux Proc
Linux下的/proc文件系统是由内核提供的.它不是一个真正的文件系统,只包含了系统运行时候的消息.(如系统内存/mount设备信息/硬件配置)
它只存在于内存中,不占用外存空间.
本质是以文件系统的方式,为访问内核数据的操作提供接口
main函数
main.go
- 启动的主函数
- 现在定义了两个命令initCommand与runCommand
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
"os"
)
const usage = `mydocker is a simple container runtime implementation.
The purpose of this project is to learn how docker works and how to write a docker by ourselves
Enjoy it, just for fun.`
func main() {
app := cli.NewApp()
app.Name = "mydocker"
app.Usage = usage
app.Commands = []cli.Command{
initCommand,
runCommand,
}
//初始化日志配置
app.Before = func(context *cli.Context) error {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{
})
log.SetOutput(os.Stdout)
return nil
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
main_command.go
- runCommand
调用Run函数
package main
import (