-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: liuminjian <[email protected]>
- Loading branch information
liuminjian
committed
Nov 24, 2023
1 parent
580b26d
commit 6db1c35
Showing
86 changed files
with
1,111 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2023 NetEase Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Project: Curveadm | ||
* Created Date: 2023-03-31 | ||
* Author: wanghai (SeanHai) | ||
*/ | ||
|
||
package http | ||
|
||
import ( | ||
"github.com/opencurve/curveadm/cli/cli" | ||
cliutil "github.com/opencurve/curveadm/internal/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewHttpCommand(curveadm *cli.CurveAdm) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "http", | ||
Short: "Manage http service", | ||
Args: cliutil.NoArgs, | ||
RunE: cliutil.ShowHelp(curveadm.Err()), | ||
} | ||
|
||
cmd.AddCommand( | ||
NewStartCommand(curveadm), | ||
NewStopCommand(curveadm), | ||
) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2023 NetEase Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Project: Curveadm | ||
* Created Date: 2023-03-31 | ||
* Author: wanghai (SeanHai) | ||
*/ | ||
|
||
package http | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"path" | ||
|
||
"github.com/opencurve/curveadm/cli/cli" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
START_EXAMPLR = `Examples: | ||
$ curveadm http start # Start an http service to receive requests` | ||
EXEC_PATH = "http/pigeon" | ||
) | ||
|
||
func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start [OPTIONS]", | ||
Short: "Start http service", | ||
Example: START_EXAMPLR, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return runStart(curveadm) | ||
}, | ||
DisableFlagsInUseLine: true, | ||
} | ||
return cmd | ||
} | ||
|
||
func runStart(curveadm *cli.CurveAdm) error { | ||
path := path.Join(curveadm.RootDir(), EXEC_PATH) | ||
cmd := exec.Command(path, "start") | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("%s", output) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2023 NetEase Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* Project: Curveadm | ||
* Created Date: 2023-03-31 | ||
* Author: wanghai (SeanHai) | ||
*/ | ||
|
||
package http | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"path" | ||
|
||
"github.com/opencurve/curveadm/cli/cli" | ||
cliutil "github.com/opencurve/curveadm/internal/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "stop", | ||
Short: "Stop http service", | ||
Args: cliutil.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return runStop(curveadm) | ||
}, | ||
DisableFlagsInUseLine: true, | ||
} | ||
return cmd | ||
} | ||
|
||
func runStop(curveadm *cli.CurveAdm) error { | ||
path := path.Join(curveadm.RootDir(), EXEC_PATH) | ||
cmd := exec.Command(path, "stop") | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("%s", output) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2023 NetEase Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/opencurve/curveadm/http" | ||
"github.com/opencurve/pigeon" | ||
) | ||
|
||
func main() { | ||
admServer := http.NewServer() | ||
pigeon.Serve(admServer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.