-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added recreate, restart, config apply and config show for relay_eth
- Loading branch information
Showing
12 changed files
with
406 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright © 2020 MARLIN TEAM <info@marlin.pro> | ||
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 actions | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
cmn "github.com/marlinprotocol/ctl2/cmd/relay/eth/common" | ||
cfg "github.com/marlinprotocol/ctl2/cmd/relay/eth/config" | ||
projectRunners "github.com/marlinprotocol/ctl2/modules/runner/relay_eth" | ||
"github.com/marlinprotocol/ctl2/types" | ||
) | ||
|
||
// AppCmd represents the registry command | ||
var RecreateCmd = &cobra.Command{ | ||
Use: "recreate", | ||
Short: "Trigger recreate for the service", | ||
Long: `Trigger recreate fot the service`, | ||
PreRunE: cfg.ConfigTest, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var projectConfig types.Project | ||
err := viper.UnmarshalKey(cmn.ProjectID, &projectConfig) | ||
if err != nil { | ||
log.Error("Error while reading project config: ", err) | ||
os.Exit(1) | ||
} | ||
|
||
runnerId, version, err := cmn.GetResourceMetaData(projectConfig, instanceId) | ||
if err != nil { | ||
log.Error("Error while fetching resource information: ", err) | ||
os.Exit(1) | ||
} | ||
|
||
runner, err := projectRunners.GetRunnerInstance(runnerId, version, projectConfig.Storage, struct{}{}, true, true, instanceId) | ||
if err != nil { | ||
log.Error("Cannot get runner: ", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
err = runner.PreRunSanity() | ||
if err != nil { | ||
log.Error("Failure during pre run sanity: ", err.Error()) | ||
return | ||
} | ||
|
||
err = runner.Recreate() | ||
if err != nil { | ||
log.Error("Failure during recreating application: ", err.Error()) | ||
return | ||
} | ||
|
||
log.Info("Restarted") | ||
}, | ||
} | ||
|
||
func init() { | ||
RecreateCmd.Flags().StringVarP(&instanceId, "instance-id", "i", "001", "instance-id of the resource") | ||
} |
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,73 @@ | ||
/* | ||
Copyright © 2020 MARLIN TEAM <info@marlin.pro> | ||
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 actions | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
cmn "github.com/marlinprotocol/ctl2/cmd/relay/eth/common" | ||
cfg "github.com/marlinprotocol/ctl2/cmd/relay/eth/config" | ||
projectRunners "github.com/marlinprotocol/ctl2/modules/runner/relay_eth" | ||
"github.com/marlinprotocol/ctl2/types" | ||
) | ||
|
||
// AppCmd represents the registry command | ||
var RestartCmd = &cobra.Command{ | ||
Use: "restart", | ||
Short: "Trigger restart for the service", | ||
Long: `Trigger restart fot the service`, | ||
PreRunE: cfg.ConfigTest, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var projectConfig types.Project | ||
err := viper.UnmarshalKey(cmn.ProjectID, &projectConfig) | ||
if err != nil { | ||
log.Error("Error while reading project config: ", err) | ||
os.Exit(1) | ||
} | ||
|
||
runnerId, version, err := cmn.GetResourceMetaData(projectConfig, instanceId) | ||
if err != nil { | ||
log.Error("Error while fetching resource information: ", err) | ||
os.Exit(1) | ||
} | ||
|
||
runner, err := projectRunners.GetRunnerInstance(runnerId, version, projectConfig.Storage, struct{}{}, true, true, instanceId) | ||
if err != nil { | ||
log.Error("Cannot get runner: ", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
err = runner.PreRunSanity() | ||
if err != nil { | ||
log.Error("Failure during pre run sanity: ", err.Error()) | ||
return | ||
} | ||
|
||
err = runner.Restart() | ||
if err != nil { | ||
log.Error("Failure during restart: ", err.Error()) | ||
return | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RestartCmd.Flags().StringVarP(&instanceId, "instance-id", "i", "001", "instance-id of the resource") | ||
} |
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,36 @@ | ||
package actions | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
cmn "github.com/marlinprotocol/ctl2/cmd/relay/eth/common" | ||
"github.com/marlinprotocol/ctl2/modules/util" | ||
"github.com/marlinprotocol/ctl2/types" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// AppCmd represents the registry command | ||
var ConfigShowCmd = &cobra.Command{ | ||
Use: "show", | ||
Short: "Show current project configuration", | ||
Long: `Show current project configuration`, | ||
PreRunE: ConfigTest, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var projectConfig types.Project | ||
err := viper.UnmarshalKey(cmn.ProjectID, &projectConfig) | ||
if err != nil { | ||
log.Error("Error while reading project configs: ", err.Error()) | ||
os.Exit(1) | ||
} | ||
s, err := json.MarshalIndent(projectConfig, "", " ") | ||
if err != nil { | ||
log.Error("Error while decoding json: ", err.Error()) | ||
os.Exit(1) | ||
} | ||
log.Info("Current config:") | ||
util.PrintPrettyDiff(string(s)) | ||
}, | ||
} |
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
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.