aboutsummaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..ea88215
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,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