✨ 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 {
|
func doPublish(c *fiber.Ctx) error {
|
||||||
var upstream *sign.UpstreamConfig
|
var workdir string
|
||||||
var site *sign.SiteConfig
|
var site *sign.SiteConfig
|
||||||
|
var upstream *sign.UpstreamConfig
|
||||||
|
var process *sign.ProcessConfig
|
||||||
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("upstream") {
|
if stream.ID == c.Params("slug") {
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,9 +37,9 @@ func doPublish(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if upstream == nil {
|
if upstream == nil && process == nil {
|
||||||
return fiber.ErrNotFound
|
return fiber.ErrNotFound
|
||||||
} else if upstream.GetType() != sign.UpstreamTypeFile {
|
} else if upstream != nil && upstream.GetType() != sign.UpstreamTypeFile {
|
||||||
return fiber.ErrUnprocessableEntity
|
return fiber.ErrUnprocessableEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +47,6 @@ 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 {
|
||||||
|
@ -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, _, 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)
|
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", status)
|
mistake = fmt.Errorf("server rejected request, status code %d, response %s", status, string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -20,7 +20,6 @@ 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
|
||||||
}
|
}
|
||||||
@ -69,8 +68,13 @@ 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 {
|
||||||
return v.Cmd.Process.Signal(os.Interrupt)
|
if err := v.Cmd.Process.Signal(os.Interrupt); err != nil {
|
||||||
} else {
|
v.Cmd.Process.Kill()
|
||||||
return nil
|
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 {
|
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!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ hypertext:
|
|||||||
key: ./cert.key
|
key: ./cert.key
|
||||||
pem: ./cert.pem
|
pem: ./cert.pem
|
||||||
limitation:
|
limitation:
|
||||||
max_body_size: -1
|
max_body_size: 536870912
|
||||||
max_qps: -1
|
max_qps: -1
|
||||||
ports:
|
ports:
|
||||||
- :8000
|
- :8000
|
||||||
|
4
test/benchmark/data/.gitignore
vendored
4
test/benchmark/data/.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
/.output
|
/ssr
|
||||||
/.spa
|
/spa
|
@ -9,7 +9,7 @@ hypertext:
|
|||||||
key: ./cert.key
|
key: ./cert.key
|
||||||
pem: ./cert.pem
|
pem: ./cert.pem
|
||||||
limitation:
|
limitation:
|
||||||
max_body_size: -1
|
max_body_size: 536870912
|
||||||
max_qps: -1
|
max_qps: -1
|
||||||
ports:
|
ports:
|
||||||
- :8000
|
- :8000
|
||||||
|
@ -8,5 +8,5 @@ upstreams:
|
|||||||
uri: http://localhost:3000
|
uri: http://localhost:3000
|
||||||
processes:
|
processes:
|
||||||
- id: nuxt-ssr
|
- id: nuxt-ssr
|
||||||
workdir: ../data
|
workdir: ../data/ssr
|
||||||
command: ["node", ".output/server/index.mjs"]
|
command: ["node", ".output/server/index.mjs"]
|
||||||
|
@ -9,7 +9,7 @@ hypertext:
|
|||||||
key: ./cert.key
|
key: ./cert.key
|
||||||
pem: ./cert.pem
|
pem: ./cert.pem
|
||||||
limitation:
|
limitation:
|
||||||
max_body_size: -1
|
max_body_size: 536870912
|
||||||
max_qps: -1
|
max_qps: -1
|
||||||
ports:
|
ports:
|
||||||
- :8000
|
- :8000
|
||||||
|
@ -9,7 +9,7 @@ hypertext:
|
|||||||
key: ./cert.key
|
key: ./cert.key
|
||||||
pem: ./cert.pem
|
pem: ./cert.pem
|
||||||
limitation:
|
limitation:
|
||||||
max_body_size: -1
|
max_body_size: 536870912
|
||||||
max_qps: -1
|
max_qps: -1
|
||||||
ports:
|
ports:
|
||||||
- :8000
|
- :8000
|
||||||
|
@ -9,7 +9,7 @@ hypertext:
|
|||||||
key: ./cert.key
|
key: ./cert.key
|
||||||
pem: ./cert.pem
|
pem: ./cert.pem
|
||||||
limitation:
|
limitation:
|
||||||
max_body_size: -1
|
max_body_size: 536870912
|
||||||
max_qps: -1
|
max_qps: -1
|
||||||
ports:
|
ports:
|
||||||
- :8000
|
- :8000
|
||||||
|
Loading…
Reference in New Issue
Block a user