✨ Can publish to process
All checks were successful
release-nightly / build-docker (push) Successful in 1m9s
All checks were successful
release-nightly / build-docker (push) Successful in 1m9s
This commit is contained in:
parent
ccc98f6633
commit
7b47004cf7
@ -12,14 +12,24 @@ import (
|
||||
)
|
||||
|
||||
func doPublish(c *fiber.Ctx) error {
|
||||
var upstream *sign.UpstreamConfig
|
||||
var workdir string
|
||||
var site *sign.SiteConfig
|
||||
var upstream *sign.UpstreamConfig
|
||||
var process *sign.ProcessConfig
|
||||
for _, item := range sign.App.Sites {
|
||||
if item.ID == c.Params("site") {
|
||||
site = item
|
||||
for _, stream := range item.Upstreams {
|
||||
if stream.ID == c.Params("upstream") {
|
||||
if stream.ID == c.Params("slug") {
|
||||
upstream = stream
|
||||
workdir, _ = stream.GetRawURI()
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, proc := range item.Processes {
|
||||
if proc.ID == c.Params("slug") {
|
||||
process = proc
|
||||
workdir = proc.Workdir
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -27,9 +37,9 @@ func doPublish(c *fiber.Ctx) error {
|
||||
}
|
||||
}
|
||||
|
||||
if upstream == nil {
|
||||
if upstream == nil && process == nil {
|
||||
return fiber.ErrNotFound
|
||||
} else if upstream.GetType() != sign.UpstreamTypeFile {
|
||||
} else if upstream != nil && upstream.GetType() != sign.UpstreamTypeFile {
|
||||
return fiber.ErrUnprocessableEntity
|
||||
}
|
||||
|
||||
@ -37,8 +47,6 @@ func doPublish(c *fiber.Ctx) error {
|
||||
process.StopProcess()
|
||||
}
|
||||
|
||||
workdir, _ := upstream.GetRawURI()
|
||||
|
||||
if c.Query("overwrite", "yes") == "yes" {
|
||||
files, _ := filepath.Glob(filepath.Join(workdir, "*"))
|
||||
for _, file := range files {
|
||||
|
@ -70,10 +70,10 @@ var DeployCommands = []*cli.Command{
|
||||
BasicAuth("RoadSign CLI", server.Credential)
|
||||
|
||||
var mistake error
|
||||
if status, _, err := client.Bytes(); len(err) > 0 {
|
||||
if status, data, err := client.Bytes(); len(err) > 0 {
|
||||
mistake = fmt.Errorf("failed to publish to remote: %q", err)
|
||||
} else if status != 200 {
|
||||
mistake = fmt.Errorf("server rejected request, status code %d", status)
|
||||
mistake = fmt.Errorf("server rejected request, status code %d, response %s", status, string(data))
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
|
@ -20,7 +20,6 @@ func (v *ProcessConfig) BootProcess() error {
|
||||
if v.Cmd != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := v.PreapreProcess(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -69,8 +68,13 @@ func (v *ProcessConfig) StartProcess() error {
|
||||
|
||||
func (v *ProcessConfig) StopProcess() error {
|
||||
if v.Cmd != nil && v.Cmd.Process != nil {
|
||||
return v.Cmd.Process.Signal(os.Interrupt)
|
||||
if err := v.Cmd.Process.Signal(os.Interrupt); err != nil {
|
||||
v.Cmd.Process.Kill()
|
||||
return err
|
||||
} else {
|
||||
v.Cmd = nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ func (v *AppConfig) Forward(ctx *fiber.Ctx, site *SiteConfig) error {
|
||||
if err := process.BootProcess(); err != nil {
|
||||
log.Warn().Err(err).Msgf("An error occurred when booting process (%s) for %s", process.ID, site.ID)
|
||||
return fiber.ErrBadGateway
|
||||
} else {
|
||||
log.Debug().Msg("process is alive!")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ hypertext:
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: -1
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
|
4
test/benchmark/data/.gitignore
vendored
4
test/benchmark/data/.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
/.output
|
||||
/.spa
|
||||
/ssr
|
||||
/spa
|
@ -9,7 +9,7 @@ hypertext:
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: -1
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
|
@ -8,5 +8,5 @@ upstreams:
|
||||
uri: http://localhost:3000
|
||||
processes:
|
||||
- id: nuxt-ssr
|
||||
workdir: ../data
|
||||
workdir: ../data/ssr
|
||||
command: ["node", ".output/server/index.mjs"]
|
||||
|
@ -9,7 +9,7 @@ hypertext:
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: -1
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
|
@ -9,7 +9,7 @@ hypertext:
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: -1
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
|
@ -9,7 +9,7 @@ hypertext:
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: -1
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
|
Loading…
Reference in New Issue
Block a user