0%

1. 目录

1.1 [/usr]/lib/systemd/system/

(软件包安装的单元)

The expectation is that /lib/systemd/system is a directory that should only contain systemd unit files which were put there by the package manager (YUM/DNF/RPM/APT/etc).

1.2 /etc/systemd/system/

(系统管理员安装的单元, 优先级更高)

Files in /etc/systemd/system are manually placed here by the operator of the system for ad-hoc software installations that are not in the form of a package. This would include tarball type software installations or home grown scripts.

阅读全文 »

1. 安装

  • 安装电池
  • 拧上三脚架

2. 平衡

调节平衡之前需要先认清三个轴:

  • 俯仰轴 相机的右侧的那个圆圈(转动改变角度)

  • 横滚轴 后方写着智云字体的那个圆圈(貌似不会转动,倾斜改变角度)

  • 航向轴 手柄上方的那个圆圈(转动改变角度)

2.1 调节平衡
  • 先调节俯仰轴水平, 前后移动快装板, 松手水平后拧紧快装板螺丝
  • 再调节俯仰轴垂直, 松手垂直后拧紧俯仰轴螺丝
  • 再调节横滚轴, 松手水平后拧紧横滚轴螺丝
  • 最后调节航向轴, 把三脚架怼着肚子,松手水平后拧紧航向轴螺丝
阅读全文 »

0. 安装

  • windows

  • mac

1. 基础操作

1.1 软件
  • 新建项目
  • 窗口->工作区->重置
  • 首选项->自动保存
阅读全文 »

1. nsq 介绍

nsq是一个基于Go语言的分布式实时消息平台,nsq可用于大规模系统中的实时消息服务,并且每天能够处理数亿级别的消息,其设计目标是为在分布式环境下运行的去中心化服务提供一个强大的基础架构。

阅读全文 »

golang从诞生之初就一直有个被诟病的问题:缺少一个行之有效的“官方”包依赖管理工具。之前golang包管理工具有数十个, 说实话都不是让人非常满意。

go 1.11 有了对模块的实验性支持,大部分的子命令都知道如何处理一个模块,比如 run build install get list mod 子命令。go 1.12 会删除对 GOPATH 的支持,go get 命令也会变成只能获取模块,不能像现在这样直接获取一个裸包。

可以用环境变量 GO111MODULE 开启或关闭模块支持,它有三个可选值:off、on、auto,默认值是 auto。

  • GO111MODULE=off 无模块支持,go 会从 GOPATH 和 vendor 文件夹寻找包。
  • GO111MODULE=on 模块支持,go 会忽略 GOPATH 和 vendor 文件夹,只根据 go.mod 下载依赖。
  • GO111MODULE=auto 在 $GOPATH/src 外面且根目录有 go.mod 文件时,开启模块支持。

在使用模块的时候,GOPATH 是无意义的,不过它还是会把下载的依赖储存在 $GOPATH/pkg/mod 中,也会把 go install 的结果放在 $GOPATH/bin 中。

阅读全文 »

1. 等待 goroutine 退出

1.1 使用Waitgroup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main

import (
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"time"
)

type Service struct {
ch chan bool
waitGroup *sync.WaitGroup
}

func NewService() *Service {
s := &Service{
ch: make(chan bool),
waitGroup: &sync.WaitGroup{},
}

return s
}

func (s *Service) Stop() {
close(s.ch) // 3. 发送golang内部关闭信号
s.waitGroup.Wait()
fmt.Println("彻底over,彻底退出") // 4. 服务真正退出
}

func (s *Service) Serve() {
fmt.Println("Server start")
s.waitGroup.Add(1)
defer s.waitGroup.Done()
index := 1
for {
select {
case <-s.ch:
fmt.Println("Server stopping...")
return
default:
time.Sleep(time.Second) // 每秒开一个go
s.waitGroup.Add(1)
go s.anotherServer(index)
index++
}
}
}

func (s *Service) anotherServer(index int) {
fmt.Println("anotherServer start", index)
defer s.waitGroup.Done()
for {
select {
case <-s.ch:
fmt.Println("anotherServer stopping...", index)
return
default:
}
}
}

func main() {
service := NewService()
go service.Serve()

ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) // 1. 卡在这里
fmt.Println("收到退出了到信号", <-ch)

service.Stop() // 2. 收到系统信号,处理清理逻辑
}

/*
Server start
anotherServer start 1
anotherServer start 2
anotherServer start 3
anotherServer start 4
^C收到退出了到信号 interrupt
anotherServer stopping... 4
anotherServer stopping... 2
anotherServer stopping... 1
anotherServer stopping... 3
Server stopping...
anotherServer start 5
anotherServer stopping... 5
彻底over,彻底退出
*/
  1. close无缓冲的channle,有广播效果。
  2. wait 所有go 退出。
阅读全文 »

我们可能同时在进行2个项目,而2个不同的项目所使用的node版本又是不一样的,或者是要用更新的node版本进行试验和学习。这种情况下,对于维护多个版本的node将会是一件非常麻烦的事情,而nvm就是为解决这个问题而产生的,他可以方便的在同一台设备上进行多个node版本之间切换,而这个正是nvm的价值所在。

1. 介绍

1.1 nodejs,npm,nvm之间的区别

  • nodejs:在项目开发时的所需要的代码库

  • npm:nodejs 包管理工具。在安装的 nodejs 的时候,npm 也会跟着一起安装,它是包管理工具。npm 管理 nodejs 中的第三方插件

  • nvm:nodejs 版本管理工具。也就是说:一个 nvm 可以管理很多 node 版本和 npm 版本。

阅读全文 »

1. npm 介绍

npm 是 Node 的模块管理器,功能极其强大。它是 Node 获得成功的重要原因之一。

npm不需要单独安装。在安装Node的时候,会连带一起安装npm。但是,Node附带的npm可能不是最新版本,最好用下面的命令,更新到最新版本。

1
npm install npm@latest -g 

上面的命令中,@latest表示最新版本,-g表示全局安装。所以,命令的主干是npm install npm,也就是使用npm安装自己。之所以可以这样,是因为npm本身与Node的其他模块没有区别。

阅读全文 »