Skip to content

Commit

Permalink
fix reload response
Browse files Browse the repository at this point in the history
  • Loading branch information
inada-s committed Jan 31, 2021
1 parent ad16813 commit d0718bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions chatops/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ async def ping(ctx):


@bot.command()
async def update_masterdata(ctx):
async def master(ctx: commands.Context):
await ctx.send("https://docs.google.com/spreadsheets/d/" + os.getenv("GDXSV_SPREADSHEET_ID"))


@bot.command()
async def master_up(ctx: commands.Context):
await ctx.send("Updating masterdata...")
try:
tables = ops.normalize_tables(ops.download_masterdata())
Expand All @@ -30,9 +35,13 @@ async def update_masterdata(ctx):
await ctx.send("Failed to update masterdata")
await ctx.send(str(e))

await ctx.send("Reloading masterdata...")

req = urllib.request.Request("http://localhost:9880/ops/reload")
with urllib.request.urlopen(req) as res:
await ctx.send(res.read())
await ctx.send(body)

await ctx.send("Done")


if __name__ == '__main__':
Expand Down
4 changes: 3 additions & 1 deletion gdxsv/lbs_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ func (lbs *Lbs) RegisterHTTPHandlers() {
})

http.HandleFunc("/ops/reload", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
lbs.Locked(func(lbs *Lbs) {
lbs.reload = true
})
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte("OK"))
})
}

0 comments on commit d0718bb

Please sign in to comment.