<p>There's no &quot;easiest&quot; way per se, there's the better way for you.
I'd recommend using a configuration management tool like Chef or Puppet (for a pull model) for which there's already resources to configure and handle logstash restarts.</p>
<p>That said logstash is able to watch its config file and reload it itself, quoting elastic.co documentation:</p>
<blockquote>
<p>Starting with Logstash 2.3, you can set Logstash to detect and reload configuration changes automatically.</p>
<p>To enable automatic config reloading, start Logstash with the <code>--config.reload.automatic</code> (or <code>-r</code>) command-line option specified. For example:</p>
<pre><code>bin/logstash –f apache.config --config.reload.automatic
</code></pre>
</blockquote>
<p>So you may just set a crontab to <code>git pull</code> your repository periodically and have logstash reload itself.</p>

CC BY-SA 4.0
2019-04-09T11:58:33.450Z
2019-04-09T11:58:33.450Z
2020-06-18T08:28:10.803Z
Tensibai
<p>I would suggest <code>jenkins</code> for this as it can easily integrate wit <code>github</code>, <code>gitlab</code> or any other SCM. Jenkins jobs can be setup such that the build runs whenever you push a commit to the <code>gitlab</code> repo. In the job, you can mention to update the logstash config on the linux VM and then reload/restart your service.</p>

<p>Here are some articles which can help you in proceeding further.</p>

<p><a href="http://fourkitchens.com/blog/article/trigger-jenkins-builds-pushing-github/" rel="nofollow noreferrer">http://fourkitchens.com/blog/article/trigger-jenkins-builds-pushing-github/</a></p>

<p><a href="https://oncomputingwell.princeton.edu/2018/01/triggering-a-jenkins-build-every-time-changes-are-pushed-to-a-git-branch-on-github/" rel="nofollow noreferrer">https://oncomputingwell.princeton.edu/2018/01/triggering-a-jenkins-build-every-time-changes-are-pushed-to-a-git-branch-on-github/</a></p>

<p>NOTE: 
If you want to setup this just for a single node, You can also create a very simple script which should pull from github, say every 5 mins, and if the changes are there, it can update logstash config and simply restart the logstash.</p>

CC BY-SA 4.0
2019-09-10T19:38:45.530Z
2019-09-10T19:38:45.530Z
Samit
<p>I have an application (Logstash) running on a Linux VM and the settings for it are on a GitLab repo. What I want is for the VM to pull the latest version of the settings file and restart the service when I push an update to the repo.</p>

<p>What is the easiest way of achieving this?</p>

<git><gitlab><cicd>
How do I automate the process of pulling the latest code and restarting a service on git push?
acurioushippo
# How do I automate the process of pulling the latest code and restarting a service on git push?

(Asked by: username_0 on 2019-04-09)

I have an application (Logstash) running on a Linux VM and the settings for it are on a GitLab repo. What I want is for the VM to pull the latest version of the settings file and restart the service when I push an update to the repo.

What is the easiest way of achieving this?

**Tags:** git, gitlab, cicd


---

## 2 answers

### Answer by username_1 on 2019-04-09. Score: 1

There's no "easiest" way per se, there's the better way for you.
I'd recommend using a configuration management tool like Chef or Puppet (for a pull model) for which there's already resources to configure and handle logstash restarts.
That said logstash is able to watch its config file and reload it itself, quoting elastic.co documentation:

Starting with Logstash 2.3, you can set Logstash to detect and reload configuration changes automatically.
To enable automatic config reloading, start Logstash with the --config.reload.automatic (or -r) command-line option specified. For example:
bin/logstash –f apache.config --config.reload.automatic


So you may just set a crontab to git pull your repository periodically and have logstash reload itself.


---

### Answer by username_2 on 2019-09-10. Score: 0

I would suggest `jenkins` for this as it can easily integrate wit `github`, `gitlab` or any other SCM. Jenkins jobs can be setup such that the build runs whenever you push a commit to the `gitlab` repo. In the job, you can mention to update the logstash config on the linux VM and then reload/restart your service.

Here are some articles which can help you in proceeding further.

<http://fourkitchens.com/blog/article/trigger-jenkins-builds-pushing-github/>

<https://oncomputingwell.princeton.edu/2018/01/triggering-a-jenkins-build-every-time-changes-are-pushed-to-a-git-branch-on-github/>

NOTE:
If you want to setup this just for a single node, You can also create a very simple script which should pull from github, say every 5 mins, and if the changes are there, it can update logstash config and simply restart the logstash.


---

