ee-core-lingyun
v1.0.4
Published
Enhanced ee-core with server management capabilities - stop, restart HTTP and Socket servers
Maintainers
Readme
EE-Core Enhanced
Enhanced version of ee-core with advanced server management capabilities.
🚀 Features
- Server Management: Stop, restart, and monitor HTTP and Socket.IO servers
- Port Persistence: Servers maintain their original port numbers after restart
- Graceful Shutdown: Properly close all connections and resources
- Status Monitoring: Real-time server status tracking
- Multiple Interfaces: HTTP API, Socket.IO, and direct function calls
- IPC Fix: Resolved "Attempted to register a second handler" error
- TypeScript Support: Full type definitions included
- Error Handling: Comprehensive error handling and logging
📦 Installation
npm install ee-core-enhanced🎯 Quick Start
const { ElectronEgg } = require('ee-core-enhanced');
// Initialize the application
const app = new ElectronEgg();
app.run();🛠️ Server Management
HTTP API
# Get server status
GET http://localhost:7070/controller/serverManager/getStatus
# Stop all servers
POST http://localhost:7070/controller/serverManager/stopAll
# Restart all servers
POST http://localhost:7070/controller/serverManager/restartAll
# Individual server management
POST http://localhost:7070/controller/serverManager/stopHttp
POST http://localhost:7070/controller/serverManager/restartHttp
POST http://localhost:7070/controller/serverManager/stopSocket
POST http://localhost:7070/controller/serverManager/restartSocketSocket.IO
const io = require('socket.io-client');
const socket = io('http://localhost:7071');
// Get server status
socket.emit('controller/serverManager/getStatus', {}, (response) => {
console.log('Server status:', response);
});
// Restart all servers
socket.emit('controller/serverManager/restartAll', {}, (response) => {
console.log('Restart result:', response);
});Direct Function Calls
const {
stopAllServers,
restartAllServers,
getServersStatus
} = require('ee-core-enhanced/socket');
// Get server status
const status = getServersStatus();
console.log('Servers status:', status);
// Stop all servers
const stopResult = await stopAllServers();
console.log('Stop result:', stopResult);
// Restart all servers
const restartResult = await restartAllServers();
console.log('Restart result:', restartResult);📋 API Reference
Server Status Response
{
"success": true,
"data": {
"httpServer": {
"isRunning": true,
"port": 7070,
"host": "localhost",
"protocol": "http://"
},
"socketServer": {
"isRunning": true,
"port": 7071,
"channel": "controller"
},
"ipcServer": {
"isRunning": true
}
}
}Available Management Functions
| Function | Description |
|----------|-------------|
| stopAllServers() | Stop all servers |
| restartAllServers() | Restart all servers |
| stopHttpServer() | Stop HTTP server only |
| restartHttpServer() | Restart HTTP server only |
| stopSocketServer() | Stop Socket server only |
| restartSocketServer() | Restart Socket server only |
| getServersStatus() | Get all servers status |
🔧 Configuration
The server management respects all existing ee-core configurations. You can configure servers in your config files:
// config/config.default.js
module.exports = {
httpServer: {
enable: true,
port: 7070,
host: 'localhost',
// ... other HTTP server options
},
socketServer: {
enable: true,
port: 7071,
// ... other Socket server options
}
};🧪 Testing
Test the port persistence and restart functionality:
# Run the restart test script
node test-restart.jsThis will verify that servers maintain their port numbers after restart.
📚 Documentation
For detailed documentation and examples, see:
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
This project is based on ee-core and extends it with server management capabilities.
📞 Support
If you have any questions or need help, please:
- Check the documentation
- Search existing issues
- Create a new issue if needed
Note: This is an enhanced version of ee-core. The main purpose is to add server restart and management capabilities while maintaining full compatibility with the original ee-core API.
