MCPcopy Create free account
hub / github.com/dim-an/cod / initMain

Function initMain

commands.go:210–253  ·  view source on GitHub ↗
(pid uint, shell string)

Source from the content-addressed store, hash-verified

208}
209
210func 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
255func apiCompleteWordsMain(_ uint, cword int, words []string) {
256 app := NewApplication()

Callers 1

mainFunction · 0.85

Calls 11

CloseMethod · 0.95
ConfigMethod · 0.95
ClientMethod · 0.95
CreateDirIfNotExistsFunction · 0.92
NewApplicationFunction · 0.85
verifyFatalFunction · 0.85
daemonizeFunction · 0.85
GetLogDirMethod · 0.80
GetRunDirMethod · 0.80
RequestMethod · 0.80
fatalFunction · 0.70

Tested by

no test coverage detected