> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loupp.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Daemons

> Manage background processes and daemons for long-running applications on your servers in Loupp

## Overview

Server daemons are background processes managed by supervisor. Loupp provides an interface for managing these processes with automatic restart capabilities.

## Creating Daemons

<Steps>
  <Step title="Access daemon management">
    Navigate to your server dashboard and click on the "Daemons" tab.
  </Step>

  <Step title="Configure daemon details">
    * **Directory**: Working directory (default: `/home/loupp/`)
    * **Command**: The command to run as a daemon
    * **User**: loupp or root
    * **No of Process**: Number of instances to run
    * **Start Seconds**: Time to wait before considering process started
    * **Stop Seconds**: Time to wait for graceful shutdown
  </Step>

  <Step title="Create daemon">
    Click "Create daemon" to create and start the daemon.
  </Step>
</Steps>

## Configuration Options

### Process Management

<AccordionGroup>
  <Accordion title="No of Process">
    Control how many instances run simultaneously.
  </Accordion>

  <Accordion title="Start Seconds">
    Time to wait before considering process successfully started.
  </Accordion>

  <Accordion title="Stop Seconds">
    Graceful shutdown timeout.
  </Accordion>
</AccordionGroup>

### Working Directory

```bash theme={null}
# Common working directory examples
/home/loupp/                    # User home directory
/home/loupp/my-site/        # Project-specific directory
```

## Common Daemon Examples

### Laravel Queue Workers

<AccordionGroup>
  <Accordion title="Basic Queue Worker">
    ```bash theme={null}
    php /home/loupp/your-site/artisan queue:work --sleep=3 --tries=3
    ```
  </Accordion>

  <Accordion title="Node.js Application">
    ```bash theme={null}
    node /home/loupp/app/server.js
    ```
  </Accordion>

  <Accordion title="Python Script">
    ```bash theme={null}
    python3 /home/loupp/scripts/monitor.py
    ```
  </Accordion>
</AccordionGroup>

## Daemon Management

### Interface

The daemon interface displays:

* **Name**: Daemon identifier with status indicator
* **User**: User account running the daemon
* **Command**: The command being executed
* **Actions**: Restart, View Logs, Delete

### Daemon Actions

<AccordionGroup>
  <Accordion title="Restart">
    Restart the daemon process(es) with current configuration.
  </Accordion>

  <Accordion title="View Logs">
    Access daemon execution logs and output.
  </Accordion>

  <Accordion title="Delete">
    Remove the daemon configuration and stop all processes.
  </Accordion>
</AccordionGroup>

## Process Monitoring

### Health Monitoring

* **Process Status**: Check if processes are running
* **Log Access**: View execution logs for debugging

### Status Indicators

* **Green dot**: Daemon is active and running
* **Red dot**: Daemon is inactive or has errors

## Log Management

### Accessing Daemon Logs

<Steps>
  <Step title="Access logs">
    Click "View Logs" on any daemon to access its execution logs.
  </Step>

  <Step title="View log content">
    Review the log output including stdout, stderr, and process status.
  </Step>

  <Step title="Refresh logs">
    Use the "Refresh Logs" button to get the latest log entries.
  </Step>
</Steps>

## Performance Optimization

### Resource Management

* Balance process count between performance and resource usage
* Set appropriate memory limits for long-running processes

## Troubleshooting

### Common Issues

<AccordionGroup>
  <Accordion title="Process Not Starting">
    * Check command syntax and paths
    * Verify user permissions
    * Check working directory access
    * Review error logs
  </Accordion>

  <Accordion title="Frequent Restarts">
    * Check for resource constraints
    * Review application errors
    * Verify configuration settings
  </Accordion>

  <Accordion title="High Resource Usage">
    * Monitor memory and CPU usage
    * Check for memory leaks
    * Review process count settings
  </Accordion>
</AccordionGroup>
