(pid uint, shell string)
| 208 | } |
| 209 | |
| 210 | func initMain(pid uint, shell string) { |
| 211 | app := NewApplication() |
| 212 | defer app.Close() |
| 213 | |
| 214 | logDir := app.Config().GetLogDir() |
| 215 | err := util.CreateDirIfNotExists(logDir) |
| 216 | verifyFatal(err) |
| 217 | |
| 218 | runDir := app.Config().GetRunDir() |
| 219 | err = util.CreateDirIfNotExists(runDir) |
| 220 | verifyFatal(err) |
| 221 | |
| 222 | err = daemonize(app.Config()) |
| 223 | verifyFatal(err) |
| 224 | |
| 225 | { // attach |
| 226 | rsp := server.AttachResponse{} |
| 227 | req := server.AttachRequest{ |
| 228 | Pid: int(pid), |
| 229 | Shell: shell, |
| 230 | CodBinaryPath: CodBinaryPath, |
| 231 | } |
| 232 | |
| 233 | err = app.Client().Request(&req, &rsp) |
| 234 | if err != nil { |
| 235 | fatal(err) |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | { // init script |
| 240 | req := server.InitScriptRequest{ |
| 241 | Pid: int(pid), |
| 242 | } |
| 243 | rsp := server.InitScriptResponse{} |
| 244 | err = app.Client().Request(&req, &rsp) |
| 245 | if err != nil { |
| 246 | fatal(err) |
| 247 | } |
| 248 | |
| 249 | for _, line := range rsp.Script { |
| 250 | fmt.Println(line) |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | func apiCompleteWordsMain(_ uint, cword int, words []string) { |
| 256 | app := NewApplication() |
no test coverage detected