> For the complete documentation index, see [llms.txt](https://developer.eagle.cool/plugin-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.eagle.cool/plugin-api/get-started/plugin-types/service.md).

# Background Service

The development of background service plugins is similar to [window plugins](/plugin-api/get-started/plugin-types/window.md), with the main difference being the timing of code execution. Background service plugins will automatically start when the software starts, while window plugins will only execute when the user clicks on them. To create a background service plugin, simply add `"serviceMode": true` to the `main` field in the `manifest.json`, as shown below:

```json
{
    "main":
    {
        "serviceMode": true,    // main difference
        "url": "index.html",
        "width": 640,
        "height": 480
    }
}
```

Background service plugins can also pop up windows, in which you can display the progress and status of the current background task, allowing users to clearly understand the current state of the plugin.

The final code is as follows:

{% tabs %}
{% tab title="manifest.json" %}

```json
{
    "id": "LBCZEHP8BBO94",
    "version": "1.0.0",
    "name": "Service Plugin",
    "logo": "/logo.png",
    "keywords": [],
    "main":
    {
        "serviceMode": true,
        "url": "index.html",
        "width": 640,
        "height": 480
    }
}
```

{% endtab %}

{% tab title="index.html" %}

```html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <script type="text/javascript" src="js/plugin.js"></script>
</head>

<body>
    <div>Background services can be without UI, but you can still display the status of background services here.</div>
</body>
</html>
```

{% endtab %}

{% tab title="plugin.js" %}

```javascript
console.log(`Plugins will be created automatically, no need for users to execute them.`);

eagle.onPluginCreate((plugin) => {
    console.log('eagle.onPluginCreate');
    console.log(plugin);
});

eagle.onPluginShow(() => {
    console.log('eagle.onPluginShow');
});

eagle.onPluginHide(() => {
    console.log('eagle.onPluginHide');
});
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Complete example code**:

<https://github.com/eagle-app/eagle-plugin-examples/tree/main/Service>
{% endhint %}

{% hint style="info" %}
Note: You can refer to [this article](/plugin-api/tutorial/manifest.md) to learn about all the configuration methods for manifest.json
{% endhint %}

{% hint style="warning" %}
**Note:** If the plugin execution process relies on a relative resource library path, you may need to use [`onLibraryChanged(callback)`](/plugin-api/api/event.md#g3tny) to make corresponding adjustments when the resource library switches, avoiding errors during the program execution.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.eagle.cool/plugin-api/get-started/plugin-types/service.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
