-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.py
More file actions
165 lines (126 loc) Β· 3.84 KB
/
deploy.py
File metadata and controls
165 lines (126 loc) Β· 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env python3
"""
Deployment Script for Crypto Trading Bot
Handles different deployment scenarios
"""
import os
import sys
import json
import argparse
import subprocess
from pathlib import Path
def deploy_local():
"""Deploy for local development"""
print("π Setting up for local development...")
# Run setup
subprocess.run([sys.executable, "setup_bot.py"])
print("β
Local deployment complete!")
print("Run: python scalping_scanner.py")
def deploy_server():
"""Deploy for server/VPS"""
print("π₯οΈ Setting up for server deployment...")
# Create systemd service file
service_content = """[Unit]
Description=Crypto Trading Bot
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/crypto-trading-bot
ExecStart=/usr/bin/python3 scalping_scanner.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
"""
with open("crypto-trading-bot.service", "w") as f:
f.write(service_content)
print("β
Created systemd service file")
print("To install:")
print("1. sudo cp crypto-trading-bot.service /etc/systemd/system/")
print("2. sudo systemctl enable crypto-trading-bot")
print("3. sudo systemctl start crypto-trading-bot")
def deploy_docker():
"""Create Docker deployment"""
print("π³ Creating Docker deployment...")
# Create Dockerfile
dockerfile_content = """FROM python:3.11-slim
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application
COPY . .
# Create config directory
RUN mkdir -p config logs results
# Run setup
RUN python setup_bot.py --non-interactive
# Default command
CMD ["python", "scalping_scanner.py"]
"""
with open("Dockerfile", "w") as f:
f.write(dockerfile_content)
# Create docker-compose.yml
compose_content = """version: '3.8'
services:
trading-bot:
build: .
container_name: crypto-trading-bot
restart: unless-stopped
volumes:
- ./config:/app/config
- ./logs:/app/logs
- ./results:/app/results
environment:
- PYTHONUNBUFFERED=1
command: python scalping_scanner.py
"""
with open("docker-compose.yml", "w") as f:
f.write(compose_content)
print("β
Docker files created")
print("To deploy:")
print("1. docker-compose build")
print("2. docker-compose up -d")
def deploy_cloud():
"""Create cloud deployment scripts"""
print("βοΈ Creating cloud deployment scripts...")
# AWS deployment script
aws_script = """#!/bin/bash
# AWS EC2 Deployment Script
# Update system
sudo apt update && sudo apt upgrade -y
# Install Python and Git
sudo apt install python3 python3-pip git -y
# Clone repository
git clone https://github.com/YOUR_USERNAME/crypto-trading-bot.git
cd crypto-trading-bot
# Run setup
python3 setup_bot.py
# Install as service
sudo cp crypto-trading-bot.service /etc/systemd/system/
sudo systemctl enable crypto-trading-bot
sudo systemctl start crypto-trading-bot
echo "β
AWS deployment complete!"
"""
with open("deploy_aws.sh", "w") as f:
f.write(aws_script)
# Make executable
os.chmod("deploy_aws.sh", 0o755)
print("β
Cloud deployment scripts created")
def main():
parser = argparse.ArgumentParser(description="Deploy Crypto Trading Bot")
parser.add_argument("--type", choices=["local", "server", "docker", "cloud"],
default="local", help="Deployment type")
args = parser.parse_args()
print("π CRYPTO TRADING BOT DEPLOYMENT")
print("=" * 50)
if args.type == "local":
deploy_local()
elif args.type == "server":
deploy_server()
elif args.type == "docker":
deploy_docker()
elif args.type == "cloud":
deploy_cloud()
if __name__ == "__main__":
main()