Compare commits

..

No commits in common. "7b47004cf78e25f753438d03d2370b2a69e74d22" and "1fb8bba5c43016905eee98ca691a882ea4ec0689" have entirely different histories.

12 changed files with 21 additions and 36 deletions

View File

@ -12,24 +12,14 @@ import (
) )
func doPublish(c *fiber.Ctx) error { func doPublish(c *fiber.Ctx) error {
var workdir string
var site *sign.SiteConfig
var upstream *sign.UpstreamConfig var upstream *sign.UpstreamConfig
var process *sign.ProcessConfig var site *sign.SiteConfig
for _, item := range sign.App.Sites { for _, item := range sign.App.Sites {
if item.ID == c.Params("site") { if item.ID == c.Params("site") {
site = item site = item
for _, stream := range item.Upstreams { for _, stream := range item.Upstreams {
if stream.ID == c.Params("slug") { if stream.ID == c.Params("upstream") {
upstream = stream upstream = stream
workdir, _ = stream.GetRawURI()
break
}
}
for _, proc := range item.Processes {
if proc.ID == c.Params("slug") {
process = proc
workdir = proc.Workdir
break break
} }
} }
@ -37,9 +27,9 @@ func doPublish(c *fiber.Ctx) error {
} }
} }
if upstream == nil && process == nil { if upstream == nil {
return fiber.ErrNotFound return fiber.ErrNotFound
} else if upstream != nil && upstream.GetType() != sign.UpstreamTypeFile { } else if upstream.GetType() != sign.UpstreamTypeFile {
return fiber.ErrUnprocessableEntity return fiber.ErrUnprocessableEntity
} }
@ -47,6 +37,8 @@ func doPublish(c *fiber.Ctx) error {
process.StopProcess() process.StopProcess()
} }
workdir, _ := upstream.GetRawURI()
if c.Query("overwrite", "yes") == "yes" { if c.Query("overwrite", "yes") == "yes" {
files, _ := filepath.Glob(filepath.Join(workdir, "*")) files, _ := filepath.Glob(filepath.Join(workdir, "*"))
for _, file := range files { for _, file := range files {

View File

@ -19,7 +19,6 @@ func InitAdministration() *fiber.App {
EnableIPValidation: true, EnableIPValidation: true,
EnablePrintRoutes: viper.GetBool("debug.print_routes"), EnablePrintRoutes: viper.GetBool("debug.print_routes"),
TrustedProxies: viper.GetStringSlice("security.administration_trusted_proxies"), TrustedProxies: viper.GetStringSlice("security.administration_trusted_proxies"),
BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"),
}) })
if viper.GetBool("performance.request_logging") { if viper.GetBool("performance.request_logging") {
@ -43,7 +42,7 @@ func InitAdministration() *fiber.App {
webhooks := app.Group("/webhooks").Name("WebHooks") webhooks := app.Group("/webhooks").Name("WebHooks")
{ {
webhooks.Put("/publish/:site/:slug", doPublish) webhooks.Put("/publish/:site/:upstream", doPublish)
} }
return app return app

View File

@ -70,10 +70,10 @@ var DeployCommands = []*cli.Command{
BasicAuth("RoadSign CLI", server.Credential) BasicAuth("RoadSign CLI", server.Credential)
var mistake error var mistake error
if status, data, err := client.Bytes(); len(err) > 0 { if status, _, err := client.Bytes(); len(err) > 0 {
mistake = fmt.Errorf("failed to publish to remote: %q", err) mistake = fmt.Errorf("failed to publish to remote: %q", err)
} else if status != 200 { } else if status != 200 {
mistake = fmt.Errorf("server rejected request, status code %d, response %s", status, string(data)) mistake = fmt.Errorf("server rejected request, status code %d", status)
} }
// Cleanup // Cleanup

View File

@ -20,6 +20,7 @@ func (v *ProcessConfig) BootProcess() error {
if v.Cmd != nil { if v.Cmd != nil {
return nil return nil
} }
if err := v.PreapreProcess(); err != nil { if err := v.PreapreProcess(); err != nil {
return err return err
} }
@ -68,13 +69,8 @@ func (v *ProcessConfig) StartProcess() error {
func (v *ProcessConfig) StopProcess() error { func (v *ProcessConfig) StopProcess() error {
if v.Cmd != nil && v.Cmd.Process != nil { if v.Cmd != nil && v.Cmd.Process != nil {
if err := v.Cmd.Process.Signal(os.Interrupt); err != nil { return v.Cmd.Process.Signal(os.Interrupt)
v.Cmd.Process.Kill()
return err
} else { } else {
v.Cmd = nil
}
}
return nil return nil
} }
}

View File

@ -22,8 +22,6 @@ func (v *AppConfig) Forward(ctx *fiber.Ctx, site *SiteConfig) error {
if err := process.BootProcess(); err != nil { if err := process.BootProcess(); err != nil {
log.Warn().Err(err).Msgf("An error occurred when booting process (%s) for %s", process.ID, site.ID) log.Warn().Err(err).Msgf("An error occurred when booting process (%s) for %s", process.ID, site.ID)
return fiber.ErrBadGateway return fiber.ErrBadGateway
} else {
log.Debug().Msg("process is alive!")
} }
} }

View File

@ -10,7 +10,7 @@ hypertext:
key: ./cert.key key: ./cert.key
pem: ./cert.pem pem: ./cert.pem
limitation: limitation:
max_body_size: 536870912 max_body_size: -1
max_qps: -1 max_qps: -1
ports: ports:
- :8000 - :8000

View File

@ -1,2 +1,2 @@
/ssr /.output
/spa /.spa

View File

@ -9,7 +9,7 @@ hypertext:
key: ./cert.key key: ./cert.key
pem: ./cert.pem pem: ./cert.pem
limitation: limitation:
max_body_size: 536870912 max_body_size: -1
max_qps: -1 max_qps: -1
ports: ports:
- :8000 - :8000

View File

@ -8,5 +8,5 @@ upstreams:
uri: http://localhost:3000 uri: http://localhost:3000
processes: processes:
- id: nuxt-ssr - id: nuxt-ssr
workdir: ../data/ssr workdir: ../data
command: ["node", ".output/server/index.mjs"] command: ["node", ".output/server/index.mjs"]

View File

@ -9,7 +9,7 @@ hypertext:
key: ./cert.key key: ./cert.key
pem: ./cert.pem pem: ./cert.pem
limitation: limitation:
max_body_size: 536870912 max_body_size: -1
max_qps: -1 max_qps: -1
ports: ports:
- :8000 - :8000

View File

@ -9,7 +9,7 @@ hypertext:
key: ./cert.key key: ./cert.key
pem: ./cert.pem pem: ./cert.pem
limitation: limitation:
max_body_size: 536870912 max_body_size: -1
max_qps: -1 max_qps: -1
ports: ports:
- :8000 - :8000

View File

@ -9,7 +9,7 @@ hypertext:
key: ./cert.key key: ./cert.key
pem: ./cert.pem pem: ./cert.pem
limitation: limitation:
max_body_size: 536870912 max_body_size: -1
max_qps: -1 max_qps: -1
ports: ports:
- :8000 - :8000