AlisChain macOS Installation Guide¶
System Requirements¶
- macOS 11 (Big Sur) or later
- 8GB RAM minimum (16GB recommended)
- 50GB free disk space
- Apple Silicon or Intel processor
Installation Steps¶
1. Install Prerequisites¶
Install Homebrew¶
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Dependencies¶
# Install required packages
brew install python@3.11 node git redis postgresql
# Start services
brew services start redis
brew services start postgresql
2. Clone Repository¶
# Create project directory
mkdir -p ~/Developer/alischain
cd ~/Developer/alischain
# Clone repository
git clone https://github.com/alischain/alischain.git .
3. Set Up Python Environment¶
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
4. Install Frontend Dependencies¶
cd frontend
npm install
5. Configure Environment¶
Create .env file:
cat > .env << EOL
ALISCHAIN_API_KEY=your_api_key
WEBSOCKET_URL=wss://api.alischain.com/ws
REDIS_URL=redis://localhost:6379
DATABASE_URL=postgresql://localhost/alischain
EOL
6. Set Up Database¶
# Create database
createdb alischain
# Run migrations
python manage.py migrate
Development Setup¶
1. Install Development Tools¶
# Install development dependencies
pip install -r requirements-dev.txt
# Install frontend development tools
npm install --save-dev @types/react @types/node
# Install Xcode Command Line Tools
xcode-select --install
2. IDE Setup¶
VS Code¶
Install recommended extensions: - Python - ESLint - Prettier - TypeScript - Solidity
Settings (settings.json):
{
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"solidity.formatter": "prettier"
}
Running Services¶
Start Backend¶
# Terminal 1
source venv/bin/activate
python server.py
Start Frontend¶
# Terminal 2
cd frontend
npm start
Production Deployment¶
1. Build Frontend¶
cd frontend
npm run build
2. Set Up Nginx¶
# Install nginx
brew install nginx
# Configure nginx
mkdir -p /usr/local/etc/nginx/sites-enabled
Create nginx configuration:
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
3. Set Up Launch Daemon¶
Create ~/Library/LaunchAgents/com.alischain.server.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.alischain.server</string>
<key>ProgramArguments</key>
<array>
<string>/Users/YOUR_USERNAME/Developer/alischain/venv/bin/python</string>
<string>/Users/YOUR_USERNAME/Developer/alischain/server.py</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/YOUR_USERNAME/Developer/alischain</string>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/YOUR_USERNAME/Library/Logs/alischain/server.log</string>
<key>StandardErrorPath</key>
<string>/Users/YOUR_USERNAME/Library/Logs/alischain/error.log</string>
</dict>
</plist>
Load service:
launchctl load ~/Library/LaunchAgents/com.alischain.server.plist
Monitoring¶
System Monitoring¶
# Install monitoring tools
brew install htop prometheus node_exporter grafana
# Start monitoring services
brew services start prometheus
brew services start node_exporter
brew services start grafana
Log Monitoring¶
# View logs
tail -f ~/Library/Logs/alischain/server.log
Backup and Recovery¶
Database Backup¶
# Create backup script
cat > backup.sh << EOL
#!/bin/bash
BACKUP_DIR="$HOME/Backups/alischain"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Backup database
pg_dump alischain > $BACKUP_DIR/db_$TIMESTAMP.sql
# Backup configuration
tar -czf $BACKUP_DIR/config_$TIMESTAMP.tar.gz .env
# Remove old backups (keep last 7 days)
find $BACKUP_DIR -type f -mtime +7 -delete
EOL
chmod +x backup.sh
Security¶
1. Firewall Configuration¶
# Enable firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
# Allow required applications
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add $(which python3)
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add $(which node)
2. SSL Configuration¶
# Install mkcert for local SSL
brew install mkcert
mkcert -install
mkcert localhost
Troubleshooting¶
Common Issues¶
Python Version Conflicts¶
# Use pyenv for Python version management
brew install pyenv
pyenv install 3.11
pyenv global 3.11
Node.js Version Issues¶
# Use nvm for Node.js version management
brew install nvm
nvm install 16
nvm use 16
Permission Issues¶
# Fix permissions
sudo chown -R $(whoami) ~/Developer/alischain
chmod -R 755 ~/Developer/alischain
Performance Tuning¶
PostgreSQL Optimization¶
# Edit postgresql.conf
vim /usr/local/var/postgresql@14/postgresql.conf
Add configurations:
shared_buffers = 2GB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
work_mem = 32MB
max_worker_processes = 8
max_parallel_workers_per_gather = 4
Redis Configuration¶
# Edit redis.conf
vim /usr/local/etc/redis.conf
Add configurations:
maxmemory 2gb
maxmemory-policy allkeys-lru
Last update:
2024-12-08