[feat] add http deployment method#365
Conversation
6c5c13f to
9624e34
Compare
|
@liuminjian BTW, we can provide command curveadm http start/stop is better? And the http service commit has already done. |
9624e34 to
6db1c35
Compare
ok |
|
|
||
| subname := fmt.Sprintf("host=%s volume=%s", options.Host, volume) | ||
| t := task.NewTask("Add Target", subname, hc.GetSSHConfig()) | ||
| t := task.NewTask("Add Target", subname, hc.GetSSHConfig(), hc.GetHttpConfig()) |
There was a problem hiding this comment.
这里的 GetSSHConfig 和 GetHttpConfig 可以合并成一个函数,比如 GetConnectConfig,然后在 NewTask 里面再做处理,这样后续有其他的连接方式控制,扩展性也会好一些。
There was a problem hiding this comment.
BTW:尽可能保持变量命名方式的一致性,比如用大写,那么可以用 SSH 和 HTTP,或者都用 ssh 和 http。
| subname := fmt.Sprintf("host=%s role=%s containerId=%s", | ||
| dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) | ||
| t := task.NewTask("Balance Leader", subname, hc.GetSSHConfig()) | ||
| t := task.NewTask("Balance Leader", subname, hc.GetSSHConfig(), hc.GetHttpConfig()) |
| @@ -0,0 +1,44 @@ | |||
| /* | |||
There was a problem hiding this comment.
这个命令我认为叫 deamon 更好一些。
另外目前的做法是安装 pigeon 二进制,然后在 http start 时启动这个二进制,其实这是没必要的,我们可以把 pigeon 的 start 命令逻辑复制到 http start 这个命令中,详见:pigeon start。
目前:
curveadm http start -> pigeon start
期待:
curveadm deamon start
| @@ -0,0 +1,71 @@ | |||
| /* | |||
There was a problem hiding this comment.
这个 HTTP 的核心逻辑建议移动到 internal 目录下,建议叫 daemon。
6db1c35 to
281ba47
Compare
a6bebd0 to
36a36a4
Compare
|
|
||
|
|
||
| # generate http service config file | ||
| local httpConfpath="${g_curveadm_home}/conf/pigeon.yaml" |
There was a problem hiding this comment.
建议在 curveadm 的主目录下新建一个 deamon 目录,配置文件 pigeon.yaml 以及一些 daemon 的日志都可以放到这个目录下
| /* | ||
| * Project: Curveadm | ||
| * Created Date: 2023-03-31 | ||
| * Author: wanghai (SeanHai) |
| func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "daemon", | ||
| Short: "Manage http service", |
| target.NewTargetCommand(curveadm), // curveadm target ... | ||
| pfs.NewPFSCommand(curveadm), // curveadm pfs ... | ||
| monitor.NewMonitorCommand(curveadm), // curveadm monitor ... | ||
| daemon.NewDaemonCommand(curveadm), // curveadm http |
|
|
||
| # output | ||
| OUTPUT := bin/curveadm | ||
| SERVER_OUTPUT := bin/pigeon |
d51ef71 to
a7b3b84
Compare
| /* | ||
| * Project: Curveadm | ||
| * Created Date: 2023-03-31 | ||
| * Author: wanghai (SeanHai) |
| /* | ||
| * Project: Curveadm | ||
| * Created Date: 2023-03-31 | ||
| * Author: wanghai (SeanHai) |
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "stop", | ||
| Short: "Stop http service", |
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "start [OPTIONS]", | ||
| Short: "Start http service", |
a7b3b84 to
5afef56
Compare
68f2c6f to
1afda6d
Compare
| */ | ||
|
|
||
| /* | ||
| * Project: Curveadm |
| */ | ||
|
|
||
| /* | ||
| * Project: Curveadm |
| */ | ||
|
|
||
| /* | ||
| * Project: Curveadm |
|
|
||
| const ( | ||
| STOP_EXAMPLR = `Examples: | ||
| $ curveadm daemon stop -c ~/.curveadm/daemon/config/pigeon.yaml # Stop an daemon http service` |
There was a problem hiding this comment.
$ curveadm daemon stop # Stop daemon service
|
|
||
| const ( | ||
| START_EXAMPLR = `Examples: | ||
| $ curveadm daemon start -c ~/.curveadm/daemon/config/pigeon.yaml # Start an daemon http service to receive requests` |
There was a problem hiding this comment.
$ curveadm daemon start # Start daemon service
|
|
||
| func (hc *HostConfig) GetProtocol() string { return hc.getString(CONFIG_PROTOCOL) } | ||
| func (hc *HostConfig) GetSSHConfig() *module.SSHConfig { | ||
|
|
| } | ||
|
|
||
| func (hc *HostConfig) GetHTTPConfig() *module.HTTPConfig { | ||
|
|
| } | ||
| } | ||
|
|
||
| func (hc *HostConfig) GetConnectConfig() *module.ConnectConfig { |
There was a problem hiding this comment.
既然有了 GetConnectConfig 函数,GetSSHConfig 和 GetHTTPConfig 这 2 个函数应该可以移除了.
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
| @@ -0,0 +1,166 @@ | |||
| /* | |||
| * Copyright (c) 2021 NetEase Inc. | |||
| return | ||
| } | ||
|
|
||
| if cfg.Protocol == SSH_PROTOCOL { |
There was a problem hiding this comment.
这里的逻辑可以简化一下:
if cfg.Protocol == HTTP_PROTOCOL {
client, err = NewHTTPClient(*cfg.GetHTTPConfig())
} else {
client, err = NewSSHClient(*cfg.GetSSHConfig())
}
if (err != nil) {
...
}
return client, err| url = "${g_db_path}" | ||
| __EOF__ | ||
| fi | ||
|
|
| } | ||
|
|
||
| func (client *HttpClient) Upload(localPath string, remotePath string) (err error) { | ||
| bodyBuf := &bytes.Buffer{} |
There was a problem hiding this comment.
这里的 upload 和 download 都太麻烦了,可以看下 resty 库,这个模块只要准备要命令就可以了,客户端这些逻辑可以交给 resty 去处理。
| } | ||
|
|
||
| func (client *HttpClient) RunCommand(ctx context.Context, command string) (out []byte, err error) { | ||
| data := make(map[string]interface{}) |
|
|
||
|
|
||
| # generate http service config file | ||
| local httpConfpath="${g_curveadm_home}/daemon/conf/pigeon.yaml" |
There was a problem hiding this comment.
这个逻辑可以单独拆成一个函数,包括上面的 curveadm.cfg 都可以单独拆一下。
1afda6d to
50d659a
Compare
6affee1 to
6661548
Compare
|
@liuminjian please fix the conflict. |
07fda7a to
36353d1
Compare
Signed-off-by: liuminjian <liuminjian@chinatelecom.cn>
|
@caoxianfei1 fixed |
Issue Number: #328
1.增加http daemon的部署方式,host增加protocol和http port字段


2.在每个host节点上部署http daemon

3.部署http daemon后能正常部署curve集群

遗留问题:目前enter指令不支持http方式