### WuKongIM HarmonyOS SDK Integration Guide
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/wukongim/harmonyos/intro.mdx
Learn how to integrate the WuKongIM SDK into your HarmonyOS projects. This guide covers the initial setup and configuration steps required to start using WuKongIM.
```ArkTS
// Example of integration steps (conceptual)
// 1. Add dependency to build.gradle
// 2. Initialize WuKongIM SDK in your application
// 3. Configure connection parameters
```
--------------------------------
### Connect and Send Message via WebSocket
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/quickstart.mdx
A JavaScript example demonstrating how to establish a WebSocket connection to WuKongIM and send a test message.
```javascript
// Connect via WebSocket
const ws = new WebSocket('ws://localhost:5200');
ws.onopen = function() {
console.log('Connected to WuKongIM');
// Send a test message
const message = {
type: 'message',
channel_id: 'test-channel',
content: 'Hello, WuKongIM!'
};
ws.send(JSON.stringify(message));
};
ws.onmessage = function(event) {
console.log('Received:', event.data);
};
```
--------------------------------
### Run WuKongIM with Docker
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/quickstart.mdx
Starts WuKongIM as a Docker container, exposing necessary ports and setting up persistent data storage.
```bash
docker run -d \
--name wukongim \
-p 5001:5001 \
-p 5100:5100 \
-p 5200:5200 \
-v wukongim-data:/wukongim/data \
wukongim/wukongim:latest
```
--------------------------------
### Related WuKongIM Installation and Configuration Guides
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/k8s/upgrade.mdx
Links to other relevant documentation sections for WuKongIM, including scaling, multi-node deployments, monitoring setup, and server configuration, which may be useful after an upgrade.
```javascript
Scale your upgraded cluster
Learn about cluster deployment
Set up monitoring for upgraded system
Configure advanced settings
```
--------------------------------
### Image Registry Configuration Examples
Source: https://github.com/wukongim/wukongimdocs/blob/main/home/README-DEPLOY.md
Provides examples of configuring the REGISTRY and NAMESPACE variables for different image registries.
```bash
# Docker Hub
REGISTRY=docker.io
NAMESPACE=your-username
# Alibaba Cloud Container Registry
REGISTRY=registry.cn-hangzhou.aliyuncs.com
NAMESPACE=your-namespace
# Tencent Cloud Container Registry
REGISTRY=ccr.ccs.tencentyun.com
NAMESPACE=your-namespace
# Private Registry
REGISTRY=your-private-registry.com
NAMESPACE=your-namespace
```
--------------------------------
### Install WuKongIM SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/wukongim/harmonyos/integration.mdx
Installs the WuKongIM HarmonyOS SDK using the ohpm package manager.
```bash
ohpm install @wukong/wkim
```
--------------------------------
### Install and Start Grafana Server
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/monitoring.mdx
Provides bash commands to add the Grafana repository, install Grafana, and start the Grafana server service.
```bash
# Add Grafana repository
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
# Install Grafana
sudo apt-get update
sudo apt-get install grafana
# Start Grafana
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
```
--------------------------------
### Complete Helm Configuration Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/k8s/multi-node.mdx
An example of a comprehensive Helm installation command for WuKongIM, demonstrating various configuration parameters like image tag, service type, persistence, and resource limits.
```bash
helm install wkim wukongim/wukongim \
-n wukongim \
--create-namespace \
--version 0.1.0 \
--set replicaCount=3 \
--set image.tag=v2.0.0 \
--set service.type=LoadBalancer \
--set persistence.enabled=true \
--set persistence.size=50Gi \
--set resources.requests.memory=4Gi \
--set resources.requests.cpu=2000m
```
--------------------------------
### Complete Helm Configuration Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/k8s/single-node.mdx
An example of a comprehensive Helm installation command for WuKongIM, demonstrating various configuration parameters like image tag, service type, persistence, and resource requests.
```bash
helm install wkim wukongim/wukongim \
-n wukongim \
--create-namespace \
--version 0.1.0 \
--set replicaCount=1 \
--set image.tag=v2.0.0 \
--set service.type=LoadBalancer \
--set persistence.enabled=true \
--set persistence.size=20Gi \
--set resources.requests.memory=2Gi \
--set resources.requests.cpu=1000m
```
--------------------------------
### Complete WuKongIM Configuration Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/monitoring.mdx
A comprehensive example of the WuKongIM configuration file (`wk.yaml`), demonstrating settings for release mode, cluster configuration, external network settings, monitoring (Prometheus API URL), and logging.
```yaml
mode: "release"
rootDir: "./wukongim_data"
# Cluster configuration (for multi-node)
cluster:
nodeId: 1001
serverAddr: "10.206.0.13:11110"
apiUrl: "http://10.206.0.13:5001"
initNodes:
- "1001@10.206.0.13:11110"
- "1002@10.206.0.14:11110"
- "1003@10.206.0.8:11110"
# External configuration
external:
ip: "119.45.229.172"
tcpAddr: "119.45.229.172:15100"
wsAddr: "ws://119.45.229.172:15200"
# Monitoring configuration
trace:
prometheusApiUrl: "http://10.206.0.13:9090"
# Logging configuration
logger:
level: "info"
dir: "./logs"
```
--------------------------------
### View WuKongIM Docker Logs
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/quickstart.mdx
Displays the logs for the running WuKongIM Docker container, helpful for troubleshooting startup issues.
```bash
docker logs wukongim
```
--------------------------------
### Environment Configuration
Source: https://github.com/wukongim/wukongimdocs/blob/main/home/README-DEPLOY.md
Copies the example environment configuration file and allows for modification.
```bash
# Copy environment configuration file
cp .env.example .env
# Modify configuration as needed
vim .env
```
--------------------------------
### Initialize SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/wukongim/javascript/integration.mdx
Get an instance of the WuKongIM SDK and configure it with essential connection details such as server address, user ID, and token.
```javascript
// Get SDK instance
const sdk = WKSDK.shared();
// Configure SDK
sdk.config({
addr: "ws://your-server.com:5200", // WebSocket server address
apiURL: "http://your-api-server.com", // API server address
uploadURL: "http://your-upload-server.com", // File upload server address
uid: "user123", // User ID
token: "user-auth-token" // User authentication token
});
```
--------------------------------
### Setup() 函数
Source: https://github.com/wukongim/wukongimdocs/blob/main/zh/getting-started/learning/plugin-development.mdx
插件启动时调用的函数,用于执行插件的初始化逻辑,例如资源加载或数据库连接。
```go
func (a *AIExample) Setup() {
// 插件初始化逻辑
fmt.Println("插件启动")
}
```
--------------------------------
### Install WuKongIM EasyJSSDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/javascript/getting-started.mdx
Provides instructions for installing the WuKongIM EasyJSSDK using different package managers or a CDN.
```bash
npm install easyjssdk
```
```bash
yarn add easyjssdk
```
```html
```
--------------------------------
### Get WuKongIM Connection Information
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/quickstart.mdx
Retrieves the TCP and WebSocket addresses for client connections by querying the route endpoint with a user ID.
```http
curl "http://localhost:5001/route?uid=testuser"
```
--------------------------------
### Batch Get User IM Addresses Request Examples
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/route/batch-address.mdx
Examples of how to call the Batch Get User IM Addresses API using cURL, JavaScript, Python, and Go.
```bash
curl -X POST "http://localhost:5001/route/batch?intranet=0" \
-H "Content-Type: application/json" \
-d '["user1", "user2", "user3"]'
```
```javascript
const userIds = ["user1", "user2", "user3"];
const response = await fetch('http://localhost:5001/route/batch?intranet=0', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(userIds)
});
const data = await response.json();
console.log(data);
```
```python
import requests
user_ids = ["user1", "user2", "user3"]
response = requests.post(
'http://localhost:5001/route/batch',
params={'intranet': 0},
json=user_ids
)
data = response.json()
print(data)
```
```go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
userIds := []string{"user1", "user2", "user3"}
jsonData, _ := json.Marshal(userIds)
resp, err := http.Post(
"http://localhost:5001/route/batch?intranet=0",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result []map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
```
--------------------------------
### Initialize WuKongIM SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/javascript/getting-started.mdx
Shows how to initialize the WuKongIM SDK with the server address, user ID, and authentication token.
```javascript
const im = WKIM.init("ws://your-wukongim-server.com:5200", {
uid: "your_user_id", // Your user ID
token: "your_auth_token" // Your authentication token
// deviceId: "optional_device_id", // Optional: Device ID
// deviceFlag: 2 // Optional: Device flag (1:APP, 2:WEB, default is 2)
});
```
--------------------------------
### WuKongIM Next Steps and Resources
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/multi-node.mdx
Provides links to key areas for further configuration and learning, including server settings, monitoring, deployment options, and API documentation.
```APIDOC
Next Steps:
- Server Configuration:
- Title: Server Configuration
- Description: Configure authentication and performance optimization.
- Link: /en/server/configuration
- Monitoring Setup:
- Title: Monitoring Setup
- Description: Set up monitoring and alerting.
- Link: /en/installation/linux/monitoring
- Single Node Deployment:
- Title: Single Node Deployment
- Description: Learn about single node deployment.
- Link: /en/installation/linux/single-node
- API Documentation:
- Title: API Documentation
- Description: Start using WuKongIM API.
- Link: /en/api/introduction
```
--------------------------------
### Get User Online Status - Go Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/user/online-status.mdx
Example of how to get user online status using Go.
```go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
userIds := []string{"user1", "user2", "user3"}
jsonData, _ := json.Marshal(userIds)
resp, err := http.Post(
"http://localhost:5001/user/onlinestatus",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result []map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
```
--------------------------------
### Get User Online Status - cURL Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/user/online-status.mdx
Example of how to get user online status using cURL.
```bash
curl -X POST "http://localhost:5001/user/onlinestatus" \
-H "Content-Type: application/json" \
-d '["user1", "user2", "user3"]'
```
--------------------------------
### Multi-Architecture Build Instructions
Source: https://github.com/wukongim/wukongimdocs/blob/main/home/README-DEPLOY.md
Instructions for testing multi-architecture build environments and building/pushing images.
```bash
# Test multi-architecture build environment
./test-multiarch.sh
# Build local image only (single-architecture, for quick testing)
make build-local
# Build and push multi-architecture images
make build # Build multi-architecture images
make push # Push to repository
# Check supported architectures of remote images
make inspect-remote
```
--------------------------------
### Get User Online Status - Python Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/user/online-status.mdx
Example of how to get user online status using Python's requests library.
```python
import requests
user_ids = ["user1", "user2", "user3"]
response = requests.post('http://localhost:5001/user/onlinestatus', json=user_ids)
data = response.json()
print(data)
```
--------------------------------
### Connect to Server
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/javascript/getting-started.mdx
A simple asynchronous code snippet demonstrating how to initiate a connection to the server using the `connect` method and handle potential errors.
```javascript
// 4. Connect to server
try {
await im.connect();
console.log("Connection successful!");
} catch (error) {
console.error("Connection failed:", error);
}
```
--------------------------------
### Get User Online Status - JavaScript Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/user/online-status.mdx
Example of how to get user online status using JavaScript's fetch API.
```javascript
const userIds = ["user1", "user2", "user3"];
const response = await fetch('http://localhost:5001/user/onlinestatus', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(userIds)
});
const data = await response.json();
console.log(data);
```
--------------------------------
### Client Connection Setup Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/route/get-address.mdx
Demonstrates how to dynamically discover IM connection addresses and establish a WebSocket connection based on the environment's protocol (HTTP or HTTPS).
```javascript
async function connectToWuKongIM() {
try {
// Get connection addresses
const addresses = await fetch('/route?intranet=0').then(r => r.json());
// Choose appropriate connection type based on environment
let connectionUrl;
if (window.location.protocol === 'https:') {
connectionUrl = addresses.wss_addr;
} else {
connectionUrl = addresses.ws_addr;
}
// Establish WebSocket connection
const ws = new WebSocket(connectionUrl);
ws.onopen = () => {
console.log('Connected to WuKongIM:', connectionUrl);
};
return ws;
} catch (error) {
console.error('Failed to connect to WuKongIM:', error);
}
}
```
--------------------------------
### Batch Get User IM Addresses Success Response Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/route/batch-address.mdx
Example of a successful response from the Batch Get User IM Addresses API, showing user IDs mapped to connection addresses.
```json
[
{
"uids": ["user1", "user2"],
"tcp_addr": "127.0.0.1:5100",
"ws_addr": "ws://127.0.0.1:5200",
"wss_addr": "wss://127.0.0.1:5300"
},
{
"uids": ["user3"],
"tcp_addr": "127.0.0.1:5101",
"ws_addr": "ws://127.0.0.1:5201",
"wss_addr": "wss://127.0.0.1:5301"
}
]
```
--------------------------------
### Start WuKongIM Service
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/multi-node.mdx
Command to start the WuKongIM service in detached mode using a configuration file.
```bash
./wukongim --config wk.yaml -d
```
--------------------------------
### Start Single-Node WuKongIM
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/learning/plugin-development.mdx
Starts a single-node instance of WuKongIM using a provided configuration file. This is necessary for testing your plugins.
```bash
go run main.go --config exampleconfig/single.yaml
```
--------------------------------
### Start WuKongIM Service
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/upgrade.mdx
Command to start the WuKongIM service using an existing configuration file, running it in the background.
```bash
# Start with existing configuration
./wukongim --config wk.yaml -d
```
--------------------------------
### Import WuKongIM SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/javascript/getting-started.mdx
Demonstrates how to import the necessary components from the WuKongIM SDK using various module systems.
```javascript
import { WKIM, WKIMChannelType, WKIMEvent } from 'easyjssdk';
```
```javascript
const { WKIM, WKIMChannelType, WKIMEvent } = require('easyjssdk');
```
```javascript
const { WKIM, WKIMChannelType, WKIMEvent } = window.EasyJSSDK;
```
--------------------------------
### Connecting to the Server
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/ios/getting-started.mdx
Shows how to initiate a connection to the server using the `connect` method of the `easySDK`. It includes basic error handling for the connection attempt.
```swift
// 4. Connect to server
Task {
do {
try await easySDK.connect()
print("Connection successful!")
} catch {
print("Connection failed:", error)
}
}
```
--------------------------------
### Get Channel Max Message Sequence (cURL)
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/message/max-message-seq.mdx
Example of how to call the Get Channel Max Message Sequence API using cURL, specifying the channel ID and type in the query parameters.
```bash
curl -X GET "http://localhost:5001/channel/max_message_seq?channel_id=group123&channel_type=2"
```
--------------------------------
### Initialize WuKongIM SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/android/getting-started.mdx
Initializes the WuKongIM EasySDK with server URL, user ID, and authentication token. Requires Android context.
```kotlin
val config = WuKongConfig.Builder()
.serverUrl("ws://your-wukongim-server.com:5200")
.uid("your_user_id") // Your user ID
.token("your_auth_token") // Your authentication token
// .deviceId("optional_device_id") // Optional: Device ID
// .deviceFlag(WuKongDeviceFlag.APP) // Optional: Device flag, default is APP
.build()
val easySDK = WuKongEasySDK.getInstance()
easySDK.init(this, config) // this is Application or Activity context
```
--------------------------------
### Get Channel Max Message Sequence (Go)
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/message/max-message-seq.mdx
Provides a Go example for fetching the maximum message sequence of a channel. It shows how to make an HTTP GET request and decode the JSON response.
```go
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/channel/max_message_seq?channel_id=group123&channel_type=2")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
```
--------------------------------
### Install TypeScript Definitions
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/wukongim/javascript/integration.mdx
Install the type definitions for WuKongIM SDK to enable TypeScript support and improve development experience.
```bash
npm install --save-dev @types/wukongimjssdk
```
--------------------------------
### Initialize WuKongIM EasySDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/ios/getting-started.mdx
This Swift code demonstrates how to initialize the WuKongIM EasySDK with essential configuration parameters like server URL, user ID, and authentication token.
```swift
let config = WuKongConfig(
serverUrl: "ws://your-wukongim-server.com:5200",
uid: "your_user_id", // Your user ID
token: "your_auth_token" // Your authentication token
// deviceId: "optional_device_id", // Optional: Device ID
// deviceFlag: .APP // Optional: Device flag, default is .APP
)
let easySDK = WuKongEasySDK(config: config)
```
--------------------------------
### Install WuKongIM Flutter EasySDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/easy/flutter/getting-started.mdx
Add the WuKongIM Flutter EasySDK dependency to your project's pubspec.yaml file and run 'flutter pub get' to install it.
```yaml
dependencies:
flutter:
sdk: flutter
wukong_easy_sdk: ^1.0.0
```
--------------------------------
### ConfigUpdate() 函数
Source: https://github.com/wukongim/wukongimdocs/blob/main/zh/getting-started/learning/plugin-development.mdx
当插件的配置在 WuKongIM 后台更新时调用,用于响应配置变更。
```go
func (a *AIExample) ConfigUpdate() {
// 配置更新处理逻辑
fmt.Printf("配置已更新: %+v\n", a.Config)
}
```
--------------------------------
### Install WuKongIM SDK
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/sdk/wukongim/javascript/integration.mdx
Install the WuKongIM JavaScript SDK using various package managers like npm, yarn, pnpm, and bun.
```bash
npm i wukongimjssdk
```
```bash
yarn add wukongimjssdk
```
```bash
pnpm add wukongimjssdk
```
```bash
bun add wukongimjssdk
```
--------------------------------
### 本地调试:启动插件
Source: https://github.com/wukongim/wukongimdocs/blob/main/zh/getting-started/learning/plugin-development.mdx
在插件项目目录下运行 `go run main.go` 来启动插件服务进行本地调试。
```bash
cd my-plugin
go run main.go
```
--------------------------------
### HarmonyOS Component Integration Example
Source: https://github.com/wukongim/wukongimdocs/blob/main/zh/sdk/wukongim/harmonyos/conversation.mdx
Provides an example of how to integrate WukongIM components within a HarmonyOS application. This snippet demonstrates the basic setup or usage pattern.
```javascript
// HarmonyOS Component Integration Example
// This is a placeholder for actual integration code.
// Actual implementation would involve importing WukongIM SDK components
// and using them within HarmonyOS UI elements or lifecycle methods.
console.log('WukongIM HarmonyOS Integration Example');
// Example of initializing a conversation component (hypothetical)
// const conversationComponent = new WukongIM.ConversationView({
// channelId: 'someChannelId',
// channelType: WKChannelType.personal
// });
// Example of handling channel type constants (hypothetical)
// const channelTypes = {
// personal: 1,
// group: 2
// };
```
--------------------------------
### Prometheus Query Language (PromQL) Examples
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/monitoring.mdx
Examples of PromQL queries to monitor WuKongIM metrics, including connection counts, message throughput, memory, and CPU usage.
```promql
# Check if WuKongIM metrics are being collected
wukongim_connections_total
# Check message throughput
rate(wukongim_messages_total[5m])
# Check memory usage
wukongim_memory_usage_bytes
# Check CPU usage
wukongim_cpu_usage_percent
```
--------------------------------
### Create Plugin Project and Initialize Go Modules
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/learning/plugin-development.mdx
Creates a new directory for your plugin, initializes Go modules, and fetches the WuKongIM Go PDK library. This sets up the basic structure for your plugin development.
```bash
mkdir my-plugin
cd my-plugin
go mod init my-plugin
go get github.com/WuKongIM/go-pdk
```
--------------------------------
### Get Channel Max Message Sequence API
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/api/message/max-message-seq.mdx
Retrieves the maximum message sequence number for a specified channel. Supports GET requests with channel_id and channel_type query parameters. Includes examples for cURL, JavaScript, Python, and Go, along with success and error response formats.
```APIDOC
GET /channel/max_message_seq
Description: Get the maximum message sequence number for a specified channel.
Query Parameters:
channel_id (string, required): Channel ID.
channel_type (integer, required): Channel type (1=personal channel, 2=group channel).
Responses:
200 OK:
Description: Successfully retrieved maximum message sequence.
Content:
application/json:
schema:
type: object
properties:
max_message_seq:
type: integer
description: Maximum message sequence number for the channel. Returns 0 if channel doesn't exist or has no messages.
400 Bad Request:
Description: Request parameter error.
500 Internal Server Error:
Description: Internal server error.
```
--------------------------------
### Troubleshooting: Container Startup Failures
Source: https://github.com/wukongim/wukongimdocs/blob/main/home/README-DEPLOY.md
Offers solutions for container startup failures, such as checking logs, port conflicts, and restarting with a different port.
```bash
# View detailed error messages
docker logs wukongim-docs
# Check if the port is occupied
netstat -tlnp | grep :80
# Run with a different port
docker run -d -p 8080:80 wukongim-docs:latest
```
--------------------------------
### Download WuKongIM Source Code
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/getting-started/learning/plugin-development.mdx
Clones the WuKongIM repository from GitHub to your local machine. This is the first step in setting up the development environment.
```bash
git clone https://github.com/WuKongIM/WuKongIM.git
cd WuKongIM
```
--------------------------------
### Install Prometheus on CentOS/RHEL
Source: https://github.com/wukongim/wukongimdocs/blob/main/en/installation/linux/monitoring.mdx
Installs Prometheus on CentOS/RHEL systems by downloading the binary, extracting it, creating a dedicated user and directories, and copying the binaries to the system's PATH. This prepares the environment for running Prometheus.
```bash
# Download Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
# Extract
tar xvfz prometheus-2.45.0.linux-amd64.tar.gz
cd prometheus-2.45.0.linux-amd64
# Create user and directories
sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus
# Copy binaries
sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
```