# Continuously Running API Code

**URL:** https://meta.discourse.org/t/continuously-running-api-code/127514
**Category:** Development
**Created:** [September 3, 2019, 7:08pm UTC](https://meta.discourse.org/t/continuously-running-api-code/127514 "2019-09-03T19:08:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kimardenmiller](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kimardenmiller/32/119631_2.png) [@kimardenmiller](https://meta.discourse.org/u/kimardenmiller)
#### Post date: [September 3, 2019, 7:08pm UTC](https://meta.discourse.org/t/continuously-running-api-code/127514/1 "2019-09-03T19:08:00Z")

</div>

We have built a set of [continuously running processes that extend Discourse behavior using the Ruby API, observing various conditions and taking actions such as sending PMs, adding users to groups, etc.](https://github.com/gomomentum/momentum_api.git) In hindsight, it may have been better to build this logic as a plugin. Now we are wondering:

1. Would it be ok / advisable to run this continuously looping set of processes on our DigitalOcean Droplet, say by cloning the repo into a directory under /var, installing Ruby, and running it there?

2. If not, any other suggestions for a production server to run such a set of processes against a Discourse instance?

3. Is there any advice, best practice to simplify migrating endpoint-oriented API code to a Plugin?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [September 9, 2019, 6:26am UTC](https://meta.discourse.org/t/continuously-running-api-code/127514/2 "2019-09-09T06:26:23Z")

</div>

A plugin would be a lot simpler here, you have access to regular jobs in plugins.

My recommendation would be to read the source of some plugins to get a good picture of what can be done and some of the guides on meta.

---

<div class="post-metadata">

### Author: ![kimardenmiller](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kimardenmiller/32/119631_2.png) [@kimardenmiller](https://meta.discourse.org/u/kimardenmiller)
#### Post date: [September 12, 2019, 5:35am UTC](https://meta.discourse.org/t/continuously-running-api-code/127514/3 "2019-09-12T05:35:41Z")

</div>

Will take that approach, @sam. Thanks for the review. 🤠
