blob: ea88215c7000de015372b4391891a224fc6c8770 (
plain)
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
|
#!/bin/bash
# JChat Deployment Script
# Sets up local domains and starts the server
set -e
echo "🚀 JChat Deployment Script"
echo "=========================="
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Configuration
API_DOMAIN="api.jchat.localhost"
WEB_DOMAIN="web.jchat.localhost"
SERVER_PORT=80
echo -e "${YELLOW}Setting up local domains...${NC}"
# Check if domains are already in /etc/hosts
if ! grep -q "$API_DOMAIN" /etc/hosts; then
echo "Adding $API_DOMAIN to /etc/hosts (requires sudo)"
echo "127.0.0.1 $API_DOMAIN" | sudo tee -a /etc/hosts > /dev/null
else
echo "$API_DOMAIN already in /etc/hosts"
fi
if ! grep -q "$WEB_DOMAIN" /etc/hosts; then
echo "Adding $WEB_DOMAIN to /etc/hosts (requires sudo)"
echo "127.0.0.1 $WEB_DOMAIN" | sudo tee -a /etc/hosts > /dev/null
else
echo "$WEB_DOMAIN already in /etc/hosts"
fi
echo -e "${GREEN}✅ Domains configured${NC}"
# Create necessary directories
echo -e "${YELLOW}Creating directories...${NC}"
mkdir -p server/log
mkdir -p server/data
mkdir -p server/data/mnesia
echo -e "${GREEN}✅ Directories created${NC}"
# Check if port is available
echo -e "${YELLOW}Checking port $SERVER_PORT...${NC}"
if lsof -Pi :$SERVER_PORT -sTCP:LISTEN -t >/dev/null ; then
echo -e "${RED}❌ Port $SERVER_PORT is already in use${NC}"
echo "Please stop the process using port $SERVER_PORT or change the port in config/sys.config"
exit 1
fi
echo -e "${GREEN}✅ Port $SERVER_PORT is available${NC}"
# Build the server
echo -e "${YELLOW}Building server...${NC}"
cd server
if ! rebar3 compile; then
echo -e "${RED}❌ Server compilation failed${NC}"
exit 1
fi
cd ..
echo -e "${GREEN}✅ Server built successfully${NC}"
# Start the server
echo -e "${YELLOW}Starting JChat server...${NC}"
echo "API: http://$API_DOMAIN"
echo "Web: http://$WEB_DOMAIN"
echo "Health: http://$API_DOMAIN/_health"
echo ""
echo "Press Ctrl+C to stop the server"
echo "=================================="
cd server
exec rebar3 shell --apps jchat
|