本文整理汇总了Golang中github.com/cloudfoundry-incubator/receptor.DesiredLRPCreateRequest类的典型用法代码示例。如果您正苦于以下问题:Golang DesiredLRPCreateRequest类的具体用法?Golang DesiredLRPCreateRequest怎么用?Golang DesiredLRPCreateRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DesiredLRPCreateRequest类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: desireLrp
func (appRunner *appRunner) desireLrp(params CreateAppParams) error {
primaryPort := uint16(0)
if params.Monitor.Port != 0 {
primaryPort = params.Monitor.Port
} else if len(params.ExposedPorts) > 0 {
primaryPort = params.ExposedPorts[0]
}
routes := appRunner.buildRoutes(params, primaryPort)
vcapAppURIs := []string{}
for _, route := range routes.AppRoutes {
vcapAppURIs = append(vcapAppURIs, route.Hostnames...)
}
vcapApplication := struct {
ApplicationName string `json:"application_name"`
ApplicationURIs []string `json:"application_uris"`
Name string `json:"name"`
URIs []string `json:"uris"`
Limits struct {
Disk int `json:"disk,omitempty"`
Memory int `json:"mem,omitempty"`
} `json:"limits,omitempty"`
}{}
vcapApplication.ApplicationName = params.Name
vcapApplication.Name = params.Name
vcapApplication.ApplicationURIs = vcapAppURIs
vcapApplication.URIs = vcapAppURIs
vcapApplication.Limits.Disk = params.DiskMB
vcapApplication.Limits.Memory = params.MemoryMB
vcapAppBytes, err := json.Marshal(vcapApplication)
if err != nil {
return err
}
envVars := buildEnvironmentVariables(params.EnvironmentVariables)
envVars = append(envVars, receptor.EnvironmentVariable{Name: "VCAP_APPLICATION", Value: string(vcapAppBytes)})
envVars = append(envVars, receptor.EnvironmentVariable{Name: "PORT", Value: fmt.Sprintf("%d", primaryPort)})
req := receptor.DesiredLRPCreateRequest{
ProcessGuid: params.Name,
Domain: lrpDomain,
RootFS: params.RootFS,
Instances: params.Instances,
Routes: routes.RoutingInfo(),
CPUWeight: params.CPUWeight,
MemoryMB: params.MemoryMB,
DiskMB: params.DiskMB,
Privileged: params.Privileged,
Ports: params.ExposedPorts,
LogGuid: params.Name,
LogSource: "APP",
MetricsGuid: params.Name,
EnvironmentVariables: envVars,
Annotation: params.Annotation,
Setup: params.Setup,
Action: &models.RunAction{
Path: params.StartCommand,
Args: params.AppArgs,
Dir: params.WorkingDir,
User: params.User,
},
}
var healthCheckArgs []string
if params.Monitor.Timeout != 0 {
healthCheckArgs = append(healthCheckArgs, "-timeout", fmt.Sprint(params.Monitor.Timeout))
}
switch params.Monitor.Method {
case PortMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port)),
LogSource: "HEALTH",
User: params.User,
}
case URLMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port), "-uri", params.Monitor.URI),
LogSource: "HEALTH",
User: params.User,
}
}
return appRunner.receptorClient.CreateDesiredLRP(req)
}
开发者ID:edwardt,项目名称:lattice,代码行数:90,代码来源:app_runner.go
示例2:
session, err := client.NewSession()
Expect(err).NotTo(HaveOccurred())
output, err := session.Output("/usr/bin/env")
Expect(err).NotTo(HaveOccurred())
Expect(string(output)).To(ContainSubstring("USER=vcap"))
Expect(string(output)).To(ContainSubstring("TEST=foobar"))
Expect(string(output)).To(ContainSubstring(fmt.Sprintf("INSTANCE_INDEX=%d", index)))
}
var (
processGuid string
fileServerStaticDir string
runtime ifrit.Process
address string
lrp receptor.DesiredLRPCreateRequest
)
BeforeEach(func() {
processGuid = helpers.GenerateGuid()
address = componentMaker.Addresses.SSHProxy
var fileServer ifrit.Runner
fileServer, fileServerStaticDir = componentMaker.FileServer()
runtime = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"router", componentMaker.Router()},
{"file-server", fileServer},
{"rep", componentMaker.Rep()},
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:ssh_test.go
示例3: desireLrp
func (appRunner *appRunner) desireLrp(params CreateAppParams) error {
primaryPort := uint16(0)
if params.Monitor.Port != 0 {
primaryPort = params.Monitor.Port
} else if len(params.ExposedPorts) > 0 {
primaryPort = params.ExposedPorts[0]
}
envVars := buildEnvironmentVariables(params.EnvironmentVariables)
envVars = append(envVars, receptor.EnvironmentVariable{Name: "PORT", Value: fmt.Sprintf("%d", primaryPort)})
var appRoutes route_helpers.AppRoutes
if params.NoRoutes {
appRoutes = route_helpers.AppRoutes{}
} else if len(params.RouteOverrides) > 0 {
routeMap := make(map[uint16][]string)
for _, override := range params.RouteOverrides {
routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
}
for port, hostnames := range routeMap {
appRoutes = append(appRoutes, route_helpers.AppRoute{
Hostnames: hostnames,
Port: port,
})
}
} else {
appRoutes = appRunner.buildDefaultRoutingInfo(params.Name, params.ExposedPorts, primaryPort)
}
req := receptor.DesiredLRPCreateRequest{
ProcessGuid: params.Name,
Domain: lrpDomain,
RootFS: params.RootFS,
Instances: params.Instances,
Routes: appRoutes.RoutingInfo(),
CPUWeight: params.CPUWeight,
MemoryMB: params.MemoryMB,
DiskMB: params.DiskMB,
Privileged: params.Privileged,
Ports: params.ExposedPorts,
LogGuid: params.Name,
LogSource: "APP",
MetricsGuid: params.Name,
EnvironmentVariables: envVars,
Setup: params.Setup,
Action: &models.RunAction{
Path: params.StartCommand,
Args: params.AppArgs,
Dir: params.WorkingDir,
},
}
var healthCheckArgs []string
if params.Monitor.Timeout != 0 {
healthCheckArgs = append(healthCheckArgs, "-timeout", fmt.Sprint(params.Monitor.Timeout))
}
switch params.Monitor.Method {
case PortMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port)),
LogSource: "HEALTH",
}
case URLMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port), "-uri", params.Monitor.URI),
LogSource: "HEALTH",
}
}
return appRunner.receptorClient.CreateDesiredLRP(req)
}
开发者ID:rajkumargithub,项目名称:lattice,代码行数:73,代码来源:app_runner.go
示例4:
Context("when the task is not privileged", func() {
BeforeEach(func() {
taskRequest.Privileged = false
})
It("fails", func() {
var task receptor.TaskResponse
Eventually(helpers.TaskStatePoller(receptorClient, taskRequest.TaskGuid, &task)).Should(Equal(receptor.TaskStateCompleted))
Expect(task.Failed).To(BeTrue())
})
})
})
Context("when a LRP that tries to do privileged things is requested", func() {
var lrpRequest receptor.DesiredLRPCreateRequest
BeforeEach(func() {
lrpRequest = helpers.PrivilegedLRPCreateRequest(helpers.GenerateGuid())
})
JustBeforeEach(func() {
err := receptorClient.CreateDesiredLRP(lrpRequest)
Expect(err).NotTo(HaveOccurred())
})
Context("when the LRP is privileged", func() {
BeforeEach(func() {
lrpRequest.Privileged = true
})
开发者ID:Gerg,项目名称:inigo,代码行数:29,代码来源:privileges_test.go
示例5: desireLrp
func (appRunner *appRunner) desireLrp(params CreateAppParams) error {
primaryPort := route_helpers.GetPrimaryPort(params.Monitor.Port, params.ExposedPorts)
private, public, err := appRunner.keygen.GenerateRSAKeyPair(2048)
if err != nil {
return err
}
routes := appRunner.buildRoutesWithDefaults(params, primaryPort)
routes.DiegoSSHRoute = &route_helpers.DiegoSSHRoute{
Port: 2222,
PrivateKey: private,
}
vcapAppURIs := []string{}
for _, route := range routes.AppRoutes {
vcapAppURIs = append(vcapAppURIs, route.Hostnames...)
}
vcapApplication := struct {
ApplicationName string `json:"application_name"`
ApplicationURIs []string `json:"application_uris"`
Name string `json:"name"`
URIs []string `json:"uris"`
Limits struct {
Disk int `json:"disk,omitempty"`
Memory int `json:"mem,omitempty"`
} `json:"limits,omitempty"`
}{}
vcapApplication.ApplicationName = params.Name
vcapApplication.Name = params.Name
vcapApplication.ApplicationURIs = vcapAppURIs
vcapApplication.URIs = vcapAppURIs
vcapApplication.Limits.Disk = params.DiskMB
vcapApplication.Limits.Memory = params.MemoryMB
vcapAppBytes, err := json.Marshal(vcapApplication)
if err != nil {
return err
}
envVars := buildEnvironmentVariables(params.EnvironmentVariables)
envVars = append(envVars, receptor.EnvironmentVariable{Name: "VCAP_APPLICATION", Value: string(vcapAppBytes)})
envVars = append(envVars, receptor.EnvironmentVariable{Name: "PORT", Value: fmt.Sprintf("%d", primaryPort)})
if _, exists := params.EnvironmentVariables["VCAP_SERVICES"]; !exists {
envVars = append(envVars, receptor.EnvironmentVariable{Name: "VCAP_SERVICES", Value: "{}"})
}
setupAction := &models.SerialAction{
Actions: []models.Action{
params.Setup,
&models.DownloadAction{
From: "http://file_server.service.dc1.consul:8080/v1/static/diego-sshd.tgz",
To: "/tmp",
User: "vcap",
},
},
}
hostKey, err := appRunner.keygen.GenerateRSAPrivateKey(2048)
if err != nil {
return err
}
req := receptor.DesiredLRPCreateRequest{
ProcessGuid: params.Name,
Domain: lrpDomain,
RootFS: params.RootFS,
Instances: params.Instances,
Routes: routes.RoutingInfo(),
CPUWeight: params.CPUWeight,
MemoryMB: params.MemoryMB,
DiskMB: params.DiskMB,
Privileged: params.Privileged,
Ports: append(params.ExposedPorts, 2222),
LogGuid: params.Name,
LogSource: "APP",
MetricsGuid: params.Name,
EnvironmentVariables: envVars,
Annotation: params.Annotation,
Setup: setupAction,
Action: &models.ParallelAction{
Actions: []models.Action{
&models.RunAction{
Path: "/tmp/diego-sshd",
Args: []string{
"-address=0.0.0.0:2222",
fmt.Sprintf("-authorizedKey=%s", public),
fmt.Sprintf("-hostKey=%s", hostKey),
},
Dir: "/tmp",
User: params.User,
},
&models.RunAction{
Path: params.StartCommand,
Args: params.AppArgs,
Dir: params.WorkingDir,
User: params.User,
//.........这里部分代码省略.........
开发者ID:rowhit,项目名称:lattice,代码行数:101,代码来源:app_runner.go
示例6:
archiveFiles = fixtures.GoServerApp()
})
JustBeforeEach(func() {
archive_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, "lrp.zip"),
archiveFiles,
)
})
AfterEach(func() {
helpers.StopProcesses(runtime)
})
Describe("desiring", func() {
var lrp receptor.DesiredLRPCreateRequest
BeforeEach(func() {
lrp = helpers.DefaultLRPCreateRequest(processGuid, "log-guid", 1)
lrp.Setup = &models.DownloadAction{
From: fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "lrp.zip"),
To: "/tmp",
User: "vcap",
}
lrp.Action = &models.RunAction{
User: "vcap",
Path: "/tmp/go-server",
Env: []models.EnvironmentVariable{{"PORT", "8080"}},
}
})
开发者ID:Gerg,项目名称:inigo,代码行数:30,代码来源:lrp_test.go
示例7: desireLrp
func (appRunner *appRunner) desireLrp(params CreateAppParams) error {
primaryPort := uint16(0)
if params.Monitor.Port != 0 {
primaryPort = params.Monitor.Port
} else if len(params.ExposedPorts) > 0 {
primaryPort = params.ExposedPorts[0]
}
envVars := buildEnvironmentVariables(params.EnvironmentVariables)
envVars = append(envVars, receptor.EnvironmentVariable{Name: "PORT", Value: fmt.Sprintf("%d", primaryPort)})
routes := appRunner.buildRoutes(params, primaryPort)
req := receptor.DesiredLRPCreateRequest{
ProcessGuid: params.Name,
Domain: lrpDomain,
RootFS: params.RootFS,
Instances: params.Instances,
Routes: routes.RoutingInfo(),
CPUWeight: params.CPUWeight,
MemoryMB: params.MemoryMB,
DiskMB: params.DiskMB,
Privileged: params.Privileged,
Ports: params.ExposedPorts,
LogGuid: params.Name,
LogSource: "APP",
MetricsGuid: params.Name,
EnvironmentVariables: envVars,
Annotation: params.Annotation,
Setup: params.Setup,
Action: &models.RunAction{
Path: params.StartCommand,
Args: params.AppArgs,
Dir: params.WorkingDir,
User: userForPrivilege(params.Privileged),
},
}
var healthCheckArgs []string
if params.Monitor.Timeout != 0 {
healthCheckArgs = append(healthCheckArgs, "-timeout", fmt.Sprint(params.Monitor.Timeout))
}
switch params.Monitor.Method {
case PortMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port)),
LogSource: "HEALTH",
User: userForPrivilege(params.Privileged),
}
case URLMonitor:
req.Monitor = &models.RunAction{
Path: "/tmp/healthcheck",
Args: append(healthCheckArgs, "-port", fmt.Sprint(params.Monitor.Port), "-uri", params.Monitor.URI),
LogSource: "HEALTH",
User: userForPrivilege(params.Privileged),
}
}
return appRunner.receptorClient.CreateDesiredLRP(req)
}
开发者ID:danhigham,项目名称:lattice,代码行数:61,代码来源:app_runner.go
注:本文中的github.com/cloudfoundry-incubator/receptor.DesiredLRPCreateRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论