Skip to content

Commit 3218379

Browse files
authored
refactor: remove built-in daemon manager (#2183)
1 parent e1e83e3 commit 3218379

File tree

19 files changed

+521
-987
lines changed

19 files changed

+521
-987
lines changed

.github/actions/tmate-action

Submodule tmate-action added at 19a49ed

.github/workflows/backend-cli-test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929

3030
steps:
3131
- uses: actions/checkout@v2
32+
with:
33+
submodules: recursive
3234

3335
- name: cache etcd
3436
id: cache-etcd
@@ -45,6 +47,15 @@ jobs:
4547
wget https://github.com/etcd-io/etcd/releases/download/v${{ matrix.etcd }}/etcd-v${{ matrix.etcd }}-linux-amd64.tar.gz
4648
tar zxvf etcd-v${{ matrix.etcd }}-linux-amd64.tar.gz
4749
50+
- name: install bats
51+
run: |
52+
git clone https://github.com/sstephenson/bats.git && cd bats
53+
sudo ./install.sh /usr/local
54+
4855
- name: run test
4956
working-directory: ./api
50-
run: sudo ./test/shell/cli_test.sh
57+
run: chmod +x ./test/shell/cli_test.sh && sudo ./test/shell/cli_test.sh
58+
59+
- name: tmate debugger
60+
if: ${{ failure() }}
61+
uses: ./.github/actions/tmate-action

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule ".github/actions/paths-filter"]
55
path = .github/actions/paths-filter
66
url = https://github.com/dorny/paths-filter.git
7+
[submodule ".github/actions/tmate-action"]
8+
path = .github/actions/tmate-action
9+
url = https://github.com/mxschmitt/action-tmate

api/cmd/install.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

api/cmd/remove.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

api/cmd/root.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ import (
2929
"github.com/apisix/manager-api/internal/log"
3030
)
3131

32-
var (
33-
forceStart bool
34-
)
35-
3632
var rootCmd = &cobra.Command{
37-
Use: "manager-api [flags]",
33+
Use: "manager-api",
3834
Short: "Apache APISIX Manager API",
3935
RunE: func(cmd *cobra.Command, args []string) error {
4036
err := manageAPI()
@@ -43,41 +39,25 @@ var rootCmd = &cobra.Command{
4339
}
4440

4541
func init() {
46-
cobra.OnInitialize(func() {
47-
var err error
48-
service, err = createService()
49-
if err != nil {
50-
fmt.Fprintf(os.Stderr, "error occurred while initializing service: %s", err)
51-
}
52-
})
53-
5442
rootCmd.PersistentFlags().StringVarP(&conf.ConfigFile, "config", "c", "", "config file")
5543
rootCmd.PersistentFlags().StringVarP(&conf.WorkDir, "work-dir", "p", ".", "current work directory")
56-
rootCmd.PersistentFlags().BoolVarP(&forceStart, "force", "f", false, "force start manager-api")
5744

5845
rootCmd.AddCommand(
5946
newVersionCommand(),
60-
newInstallCommand(),
61-
newRemoveCommand(),
62-
newStartCommand(),
63-
newStopCommand(),
64-
newStatusCommand(),
6547
)
6648
}
6749

6850
func Execute() {
6951
if err := rootCmd.Execute(); err != nil {
70-
_, _ = fmt.Fprintln(os.Stderr, err.Error())
52+
_, _ = fmt.Fprintln(os.Stderr, err)
7153
}
7254
}
7355

7456
func manageAPI() error {
7557
conf.InitConf()
7658
log.InitLogger()
7759

78-
s, err := server.NewServer(&server.Options{
79-
ForceStart: forceStart,
80-
})
60+
s, err := server.NewServer(&server.Options{})
8161
if err != nil {
8262
return err
8363
}
@@ -94,7 +74,7 @@ func manageAPI() error {
9474
case sig := <-quit:
9575
log.Infof("The Manager API server receive %s and start shutting down", sig.String())
9676
s.Stop()
97-
log.Infof("The Manager API server exited")
77+
log.Infof("See you next time!")
9878
case err := <-errSig:
9979
log.Errorf("The Manager API server start failed: %s", err.Error())
10080
return err

api/cmd/service.go

Lines changed: 0 additions & 94 deletions
This file was deleted.

api/cmd/start.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

api/cmd/status.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)