# Custom Amiga Brain app issues/questions

**URL:** <https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298>\
**Category:** support\
**Tags:** amiga-brain\
**Created:** [February 9, 2024, 6:18pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298 "2024-02-09T18:18:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![genkikondo](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@genkikondo](https://discourse.farm-ng.com/u/genkikondo)\
**Post date:** [February 9, 2024, 6:18pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298/1 "2024-02-09T18:18:58Z")

</div>

I am building a custom app for the Amiga Brain (FastAPI + ReactJS) based on the template ([GitHub - farm-ng/amiga-app-template](https://github.com/farm-ng/amiga-app-template)) and I’ve successfully deployed the app. However, I am running into several issues:

- The keypad does not appear on input fields. I’m just using components with with type “text” and “number”.
- Is there a way to keep the app running in the background? I’d like to be able to run another app simultaneously.
- Does the app get killed when the screen turns off? I’ve run into several cases where the server seemingly randomly shuts down on its own while the UI is still up.
- Is there a way to visualize/interact with the Brain display for testing and debugging remotely?

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![patrick](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.farm-ng.com/patrick/32/239_2.png) [@patrick](https://discourse.farm-ng.com/u/patrick)\
**Post date:** [February 9, 2024, 10:27pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298/2 "2024-02-09T22:27:05Z")

</div>

> [@genkikondo](#):
>
> The keypad does not appear on input fields. I’m just using components with with type “text” and “number”.

We recommend [react-simple-keyboard](https://www.npmjs.com/package/react-simple-keyboard) for virtual keyboard input.

> [@genkikondo](#):
>
> Is there a way to keep the app running in the background? I’d like to be able to run another app simultaneously.

We plan to support backgrounding apps more cleanly, but in the meantime, you can achieve this by lightly abusing our service/app lifecycle in your [manifest](https://amiga.farm-ng.com/docs/brain/brain-apps-manifest):

- A `service` may run continuously and potentially serve multiple apps.
- An `app` is started / stopped when the user selects / exits the application on screen. The launcher enforces that only one app is running at a time.

So, you can register your main application backend as a `service` to keep it always running. You’ll still need to register a dummy `app` if you want it to appear in the launcher UI. Your manifest will look similar to:

```auto
{
  "services": {
    "my-app-service": {
      "name": "my-app-service",
      "type": "service",
      "exec_cmd": "/mnt/managed_home/farm-ng-user-YOUR_USER_HERE/my-app/venv/bin/python3
                   /mnt/managed_home/farm-ng-user-YOUR_USER_HERE/my-app/main.py",
      "autostart": true
    },
    "my-app": {
      "name": "my-app",
      "type": "app",
      "exec_cmd": "/usr/bin/sleep inf",
      "deps": [
        "my-app-service"
      ],
      "http_gui_port": 8042,
      "display_name": "My App"
    }
  }
}

```

> [@genkikondo](#):
>
> Does the app get killed when the screen turns off? I’ve run into several cases where the server seemingly randomly shuts down on its own while the UI is still up.

No, the app process should continue to run and still be there when you wake up the screen. [Debugging the App on the Launcher](https://amiga.farm-ng.com/docs/brain/app-ownership#debugging-the-app-on-the-launcher) may help with troubleshooting.

> [@genkikondo](#):
>
> Is there a way to visualize/interact with the Brain display for testing and debugging remotely?

Yes. First [configure cross-network access](https://amiga.farm-ng.com/docs/ssh/#recommended-configure-cross-network-access), if you haven’t already. Then you have two options:

1. [Use a VNC viewer](https://amiga.farm-ng.com/docs/examples/vnc_viewer/) to interact remotely with the full Brain display.
2. [Remote access via web browser](https://amiga.farm-ng.com/docs/apps/autoplot_app/#remote-access-via-web-browser), similar to the linked instructions for Autoplot, but substitute the `http_gui_port` registered to your application.

---

<div class="post-metadata">

**Author:** ![genkikondo](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@genkikondo](https://discourse.farm-ng.com/u/genkikondo)\
**Post date:** [February 9, 2024, 11:56pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298/3 "2024-02-09T23:56:05Z")

</div>

Awesome, this is very helpful. Thank you Patrick.

---

<div class="post-metadata">

**Author:** ![genkikondo](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@genkikondo](https://discourse.farm-ng.com/u/genkikondo)\
**Post date:** [February 14, 2024, 8:02pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298/4 "2024-02-14T20:02:57Z")

</div>

> [@genkikondo](#):
>
> Does the app get killed when the screen turns off? I’ve run into several cases where the server seemingly randomly shuts down on its own while the UI is still up.

@patrick I’ve tried implementing the same app with Kivy, and run into this again - without any user input, my app just stopped and went back to the brain’s menu. The logs show that systemd stopped the app:

> […]  
> Feb 14 19:18:46 entry.sh[167656]: [INFO] [GL] BGRA texture support is available  
> Feb 14 19:23:05 systemd[4432]: Stopping “farm-ng-user- development service ”…  
> Feb 14 19:23:05 entry.sh[167656]: [INFO] [Window] exiting mainloop and closing.

This is problematic as my app starts async automation tasks that may need to run for hours. What might be causing this? Is there anything I can help check on my end?

---

<div class="post-metadata">

**Author:** ![kylecoble](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.farm-ng.com/kylecoble/32/12_2.png) [@kylecoble](https://discourse.farm-ng.com/u/kylecoble)\
**Post date:** [February 15, 2024, 8:11pm UTC](https://discourse.farm-ng.com/t/custom-amiga-brain-app-issues-questions/298/5 "2024-02-15T20:11:56Z")

</div>

Hi @genkikondo,

I’ll jump in alongside @patrick to help you through this 🙂

> This is problematic as my app starts async automation tasks that may need to run for hours.

If your app is starting a long duration background async task, would you consider setting this part up as a (headless) service that an app communicates with? This would be similar to what @patrick has recommended above, and an app with a frontend (kivy or react) could trigger this process to start through any communication framework, including gRPC, FastAPI, etc. depending on how you set up the service. A kivy app managing an hours-long duration background task is not ideal IMO, and this would allow you to start and stop your app to initialize, monitor progress, gather results etc. as a separate process from the background task.

> What might be causing this? Is there anything I can help check on my end?

I’m not sure, it’s not something we’ve experienced yet. Does this coincide with any other event, such as the screen display turning off after periods of no activity? Does this happen when you manually launch your app from the command line as a python executable? Do you have sufficient logging in your application to confirm there is not something internal to the app causing it to crash?

Please share any other observations that may be relevant.

Thanks,  
– Kyle
