@@ -43,8 +43,8 @@ func NewCvmBootManager(config *config.CvmConfig) (CvmBootManager, error) {
4343
4444// Start starts the cvm service
4545func (s * cvmBootManager ) Start () {
46- s .startTask (s .cvmBootSequence .CvmAssistants )
47- s .startTask (s .cvmBootSequence .AppInfo )
46+ s .processTasks (s .cvmBootSequence .CvmAssistants )
47+ s .processTasks (s .cvmBootSequence .AppInfo )
4848}
4949
5050// loadConfig loads the cvm app config
@@ -58,10 +58,14 @@ func (cbm *cvmBootManager) loadConfig() (*CvmBootSequence, error) {
5858 if err != nil {
5959 return nil , fmt .Errorf ("unmarshal %s failed, error: %s" , cbm .config .ConfigPath , err .Error ())
6060 }
61+ // validate cvmBootSequence, we want no more than one app
62+ if len (cvmBootSequence .AppInfo ) >= 1 {
63+ return nil , fmt .Errorf ("only one application is supported, but got %d" , len (cvmBootSequence .AppInfo ))
64+ }
6165 return cvmBootSequence , nil
6266}
6367
64- func (cbm * cvmBootManager ) DoJob (taskInfo * TaskInfo ) error {
68+ func (cbm * cvmBootManager ) executeTask (taskInfo * TaskInfo ) error {
6569 if taskInfo .Type != JOB {
6670 return fmt .Errorf ("this task is not a job" )
6771 }
@@ -87,7 +91,7 @@ func (cbm *cvmBootManager) DoJob(taskInfo *TaskInfo) error {
8791
8892}
8993
90- func (cbm * cvmBootManager ) CreateSevers (taskInfo * TaskInfo ) error {
94+ func (cbm * cvmBootManager ) deployService (taskInfo * TaskInfo ) error {
9195 if taskInfo .Type != SERVER {
9296 return fmt .Errorf ("task is not a server" )
9397 }
@@ -140,20 +144,20 @@ func (cbm *cvmBootManager) CreateSevers(taskInfo *TaskInfo) error {
140144 return nil
141145}
142146
143- func (cbm * cvmBootManager ) startTask (tasks []* TaskInfo ) {
147+ func (cbm * cvmBootManager ) processTasks (tasks []* TaskInfo ) {
144148 for i , t := range tasks {
145149 switch t .Type {
146150 case JOB :
147151 log .Printf ("begin to do job %s\n " , t .Name )
148- err := cbm .DoJob (t )
152+ err := cbm .executeTask (t )
149153 if err != nil {
150154 log .Fatalf ("do job %s failed, error: %s\n " , t .Name , err .Error ())
151155 }
152156 log .Printf ("end to do job %s\n " , t .Name )
153157 case SERVER :
154158 log .Printf ("begin to deploy server %s\n " , t .Name )
155159 t .Priority = i + 2
156- err := cbm .CreateSevers (t )
160+ err := cbm .deployService (t )
157161 if err != nil {
158162 log .Fatalf ("deploy server %s failed, error: %s\n " , t .Name , err )
159163 }
0 commit comments