Skip to content

Commit

Permalink
add initialize handler for pdns and add index to records
Browse files Browse the repository at this point in the history
  • Loading branch information
yyamada12 committed Nov 25, 2023
1 parent 66a0cec commit ff73065
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions webapp/go/main.go
Expand Up @@ -282,6 +282,25 @@ func initializeHandler(c echo.Context) error {
})
}

func initializeDNSHandler(c echo.Context) error {
if out, err := exec.Command("../pdns/init_zone.sh").CombinedOutput(); err != nil {
c.Logger().Warnf("init_zone.sh failed with err=%s", string(out))
return echo.NewHTTPError(http.StatusInternalServerError, "failed to initialize: "+err.Error())
}

// if err := os.RemoveAll("/home/isucon/webapp/icon/"); err != nil {
// return echo.NewHTTPError(http.StatusInternalServerError, "failed to remove directory: "+err.Error())
// }
// if err := os.Mkdir("/home/isucon/webapp/icon/", 0755); err != nil {
// return echo.NewHTTPError(http.StatusInternalServerError, "failed to create directory: "+err.Error())
// }

c.Request().Header.Add("Content-Type", "application/json;charset=utf-8")
return c.JSON(http.StatusOK, InitializeResponse{
Language: "golang",
})
}

func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
Expand All @@ -298,6 +317,7 @@ func main() {

// 初期化
e.POST("/api/initialize", initializeHandler)
e.POST("/api/initialize_dns", initializeDNSHandler)

// top
e.GET("/api/tag", getTagHandler)
Expand Down
1 change: 1 addition & 0 deletions webapp/pdns/add-index.sql
@@ -0,0 +1 @@
CREATE INDEX idx_records_name_type ON records(name, type);

0 comments on commit ff73065

Please sign in to comment.