# How use Stop method?

**URL:** <https://discuss.elastic.co/t/how-use-stop-method/155833>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [November 8, 2018, 7:42am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833 "2018-11-08T07:42:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhaoya881010](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zhaoya881010](https://discuss.elastic.co/u/zhaoya881010)\
**Post date:** [November 8, 2018, 7:42am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/1 "2018-11-08T07:42:57Z")

</div>

i found start filebeat "cmd.RootCmd.Execute()" method,but i don't know stop method.  
no Stop api in the simple cmd interface,i don't hope stoped by "ctrl+c/d". the filebeat as module to my app. i hope i call “cmd.RootCmd.Stop()”😃

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [November 8, 2018, 2:45pm UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/2 "2018-11-08T14:45:02Z")

</div>

What is your use case? Do you want to start a Filebeat instance from Golang code?

---

<div class="post-metadata">

**Author:** ![zhaoya881010](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zhaoya881010](https://discuss.elastic.co/u/zhaoya881010)\
**Post date:** [November 9, 2018, 12:09am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/3 "2018-11-09T00:09:48Z")

</div>

yes,but i found cmd.RootCmd.Execute and no Stop method."crtl c/d" is not good way,it killall.

---

<div class="post-metadata">

**Author:** ![zhaoya881010](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zhaoya881010](https://discuss.elastic.co/u/zhaoya881010)\
**Post date:** [November 9, 2018, 12:18am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/4 "2018-11-09T00:18:14Z")

</div>

example code in project:  
start:  
go func(){  
//start filebeat instance  
cmd.RootCmd.Execute()  
}  
//if filebeat.yam updated,stop filebeat instance and start.  
go func(){  
//stop method  
//start method  
cmd.RootCmd.Execute()  
}

stop method is exist in filebeat code.but it was no obvious exposure. i don't know use it.

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [November 9, 2018, 8:27am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/5 "2018-11-09T08:27:14Z")

</div>

What is your use case? What do you want to automate with your code? Do you need to reload configuration if one of the files changed? Have you looked at this documentation? [https://www.elastic.co/guide/en/beats/filebeat/current/\_live\_reloading.html](https://www.elastic.co/guide/en/beats/filebeat/current/_live_reloading.html)

Filebeat is not intended to be used this way. If you really need to start and stop Filebeat from Golang I suggest you the `exec` package to start and stop: [https://golang.org/pkg/os/exec/](https://golang.org/pkg/os/exec/)

Examples:  
Starting Filebeat

```auto
cmd := exec.Command("./filebeat")
err := cmd.Start()
if err != nil {
    log.Errorf("Error while running Filebeat: %+v", err)
}

```

Stopping Filebeat

```auto
cmd.Process.Kill()

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 7, 2018, 8:27am UTC](https://discuss.elastic.co/t/how-use-stop-method/155833/6 "2018-12-07T08:27:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
