# SIP2 & Task Scheduler Setup Guide


## 1. SIP2 Configuration

You need to configure your SIP2 settings within the `sip2.php` file. Below are the key parameters to set.

- **PHP_EXECUTABLE_PATH**: The full path to your PHP executable.
  - *Example*:  
    ```
    C:\Users\arbib\.pvm\versions\php-7.4.9-Win32-vc15-x64\php in windows
    /usr/local/bin/ea-php74 in linux
    ```
- **ARTISAN_EXECUTABLE_PATH**: The full path to the root of your Laravel project.
  - *Example*:  
    ```
    E:\Projects\Laragon\afaq\ in windows
    /home/utasafaqlib/public_html/artisan in linux
    ```
- **Public IP**: The public IP address the SIP2 server will listen on.
- **Port**: The port number for the SIP2 server.
- **Terminal Password**: The password required for the terminal.
- **Patron Login with Password**: Configure whether patrons need a password to log in.

Make sure these values are correctly set in your `sip2.php` configuration file.

---

## 2. Deploy SIP2 Worker to Queue

In order to make the SIP2 worker function properly, you need to deploy the SIP2 ServiceWatcher job to the queue.  

Run the following Artisan command:


In the interactive prompt, select:


This will dispatch the SIP2 ServiceWatcher job onto your queue so it can start processing SIP2 connections.

---

## 3. Windows Task Scheduler Setup

Follow these steps to create a scheduled task that runs your Laravel queue worker every minute.

### Step-by-Step Instructions

1. **Open Task Scheduler**  
   Press `Win + R`, type `taskschd.msc`, and press Enter.

2. **Create Task**  
   In the **Actions** pane on the right, click **Create Task...** (do not use "Create Basic Task").

3. **General Tab**
   - **Name**: Give your task a descriptive name (e.g., "Laravel Queue Worker").
   - **Security options**: Select **"Run whether user is logged on or not"**.

4. **Triggers Tab**
   - Click **New...**.
   - Under "Settings", select **One time**.
   - Check **Repeat task every:** box.
   - Set the interval to **1 minute**.
   - Set the duration to **Indefinitely**.
   - Ensure **Enabled** is checked.
   - Click **OK**.

5. **Actions Tab**
   - Click **New...**.
   - **Action**: Select **Start a program**.
   - **Program/script**: Enter the full path to your PHP executable.  
     Example:
     ```
     C:\Users\arbib\.pvm\versions\php-7.4.9-Win32-vc15-x64\php.exe
     ```
     *(Note: The user provided two different paths. Use the one that matches your system. Another example:)*  
     ```
     C:\Users\soufi\.pvm\versions\php-7.4.9-Win32-vc15-x64\php.exe
     ```
   - **Add arguments (optional)**: Enter the script path and Artisan command.  
     Example:
     ```
     -f "E:\Projects\Laragon\afaq\artisan" queue:run
     ```
     *(Or using the second example path:)*
     ```
     -f "D:\LiveProjects\www\afaq\artisan" queue:run
     ```
   - Click **OK**.

6. **Settings Tab**
   - For **"If the task is already running, then the following rule applies:"**, select **Run a new instance in parallel**.

7. **Save the Task**
   - Click **OK** to save the task.
   - You may be prompted to enter the password for the user account running the task.

Your task is now configured to run the Laravel queue every minute indefinitely.
