MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / createSymLinks

Method createSymLinks

internal/apps/app_cmd.go:298–342  ·  view source on GitHub ↗

创建软链接

()

Source from the content-addressed store, hash-verified

296
297// 创建软链接
298func (this *AppCmd) createSymLinks() error {
299 if runtime.GOOS != "linux" {
300 return nil
301 }
302
303 var exe, _ = os.Executable()
304 if len(exe) == 0 {
305 return nil
306 }
307
308 var errorList = []string{}
309
310 // bin
311 {
312 var target = "/usr/bin/" + teaconst.ProcessName
313 old, _ := filepath.EvalSymlinks(target)
314 if old != exe {
315 _ = os.Remove(target)
316 err := os.Symlink(exe, target)
317 if err != nil {
318 errorList = append(errorList, err.Error())
319 }
320 }
321 }
322
323 // log
324 {
325 var realPath = filepath.Dir(filepath.Dir(exe)) + "/logs/run.log"
326 var target = "/var/log/" + teaconst.ProcessName + ".log"
327 old, _ := filepath.EvalSymlinks(target)
328 if old != realPath {
329 _ = os.Remove(target)
330 err := os.Symlink(realPath, target)
331 if err != nil {
332 errorList = append(errorList, err.Error())
333 }
334 }
335 }
336
337 if len(errorList) > 0 {
338 return errors.New(strings.Join(errorList, "\n"))
339 }
340
341 return nil
342}
343
344func (this *AppCmd) callDirective(code string) {
345 for _, directive := range this.directives {

Callers 1

runStartMethod · 0.95

Calls 2

RemoveMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected