-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add tmux-based development setup script #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
its-me-abhishek
merged 2 commits into
CCExtractor:main
from
Hell1213:feat/155-tmux-setup-Hell1213
Nov 7, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| # CCSync Development Setup | ||
|
|
||
| This directory contains scripts to automate local development setup for CCSync. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also maybe Add a note that the backend shall be run in a separate user only (preferably root user) |
||
|
|
||
| The `setup.sh` script starts all three services (backend, frontend, and sync server) in a single tmux session with separate panes for each service. | ||
|
|
||
| > **Note:** The backend should ideally be run in a separate user environment (preferably root user) to avoid permission issues with Taskwarrior configuration files. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before running the setup script, ensure you have the following installed: | ||
|
|
||
| - **Go** (1.19 or higher) - [Installation Guide](https://go.dev/doc/install) | ||
| - **Node.js** (16 or higher) and **npm** - [Installation Guide](https://nodejs.org/) | ||
| - **Docker** and **Docker Compose** - [Installation Guide](https://docs.docker.com/get-docker/) | ||
| - **tmux** - Terminal multiplexer | ||
| - macOS: `brew install tmux` | ||
| - Ubuntu/Debian: `sudo apt-get install tmux` | ||
| - Fedora: `sudo dnf install tmux` | ||
|
|
||
| ## Environment Configuration | ||
|
|
||
| The setup script requires environment files for both backend and frontend. Create these files before running the script. | ||
|
|
||
| ### Backend Environment (`./backend/.env`) | ||
|
|
||
| Create a file at `./backend/.env` (relative to project root) with the following content: | ||
|
|
||
| ```bash | ||
| CLIENT_ID="your_google_client_id" | ||
| CLIENT_SEC="your_google_client_secret" | ||
| REDIRECT_URL_DEV="http://localhost:8000/auth/callback" | ||
| SESSION_KEY="your_random_session_key" | ||
| FRONTEND_ORIGIN_DEV="http://localhost:5173" | ||
| CONTAINER_ORIGIN="http://localhost:8080/" | ||
| ``` | ||
|
|
||
| **How to get Google OAuth credentials:** | ||
|
|
||
| For detailed instructions, refer to the [CCSync Documentation](https://its-me-abhishek.github.io/ccsync-docs/). | ||
|
|
||
| Quick steps: | ||
|
|
||
| 1. Go to [Google Cloud Console](https://console.cloud.google.com/) | ||
| 2. Create a new project or select an existing one | ||
| 3. Navigate to "APIs & Services" > "Credentials" | ||
| 4. Click "Create Credentials" > "OAuth 2.0 Client ID" | ||
| 5. Configure the OAuth consent screen if prompted | ||
| 6. Select "Web application" as the application type | ||
| 7. Add authorized redirect URI: `http://localhost:8000/auth/callback` | ||
| 8. Copy the Client ID and Client Secret | ||
|
|
||
| **Generate SESSION_KEY:** | ||
|
|
||
| You can generate a random session key using: | ||
|
|
||
| ```bash | ||
| openssl rand -base64 32 | ||
| ``` | ||
|
|
||
| ### Frontend Environment (`frontend/.env`) | ||
|
|
||
| Create a file at `frontend/.env` with the following content: | ||
|
|
||
| ```bash | ||
| VITE_BACKEND_URL="http://localhost:8000/" | ||
| VITE_FRONTEND_URL="http://localhost:5173" | ||
| VITE_CONTAINER_ORIGIN="http://localhost:8080/" | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Starting the Development Environment | ||
|
|
||
| From the project root directory: | ||
|
|
||
| 1. Make the script executable (first time only): | ||
|
|
||
| ```bash | ||
| chmod +x development/setup.sh | ||
| ``` | ||
|
|
||
| 2. Run the setup script: | ||
|
|
||
| ```bash | ||
| ./development/setup.sh | ||
| ``` | ||
|
|
||
| The script will: | ||
|
|
||
| - Verify all prerequisites are installed | ||
| - Check that environment files exist | ||
| - Install dependencies if needed (Go modules and npm packages) | ||
| - Start all three services in a tmux session | ||
| - Automatically attach you to the session | ||
|
|
||
| ### Accessing the Services | ||
|
|
||
| Once running, you can access: | ||
|
|
||
| - **Frontend**: http://localhost:5173 | ||
| - **Backend API**: http://localhost:8000 | ||
| - **API Documentation**: http://localhost:8000/api/docs/index.html | ||
| - **Sync Server**: http://localhost:8080 (started via `docker-compose up syncserver`) | ||
|
|
||
| ### Tmux Commands | ||
|
|
||
| - **Detach from session** (keep services running): Press `Ctrl+b`, then `d` | ||
| - **Reattach to session**: `tmux attach -t ccsync` | ||
| - **Navigate between panes**: `Ctrl+b` then arrow keys | ||
| - **Scroll in a pane**: `Ctrl+b` then `[`, use arrow keys, press `q` to exit | ||
|
|
||
| ### Stopping the Development Environment | ||
|
|
||
| To stop all services and clean up: | ||
|
|
||
| 1. Make the stop script executable (first time only): | ||
|
|
||
| ```bash | ||
| chmod +x development/stop.sh | ||
| ``` | ||
|
|
||
| 2. Run the stop script: | ||
|
|
||
| ```bash | ||
| ./development/stop.sh | ||
| ``` | ||
|
|
||
| This will kill the tmux session and stop all Docker containers. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Port Already in Use | ||
|
|
||
| If you see errors about ports already being in use: | ||
|
|
||
| ```bash | ||
| # Check what's using the ports | ||
| lsof -i :8000 # Backend | ||
| lsof -i :5173 # Frontend | ||
| lsof -i :8080 # Sync Server | ||
|
|
||
| # Kill the process using the port | ||
| kill -9 <PID> | ||
| ``` | ||
|
|
||
| ### Docker Not Running | ||
|
|
||
| Ensure Docker Desktop is running or start the Docker daemon: | ||
|
|
||
| ```bash | ||
| # macOS/Linux | ||
| sudo systemctl start docker | ||
|
|
||
| # Or start Docker Desktop application | ||
| ``` | ||
|
|
||
| ### Permission Denied Errors | ||
|
|
||
| If you encounter permission errors with Taskwarrior: | ||
|
|
||
| ```bash | ||
| # Ensure your user has write permissions | ||
| chmod 644 ~/.taskrc | ||
| ``` | ||
|
|
||
| ### Dependencies Not Installing | ||
|
|
||
| If Go modules or npm packages fail to install: | ||
|
|
||
| ```bash | ||
| # Backend | ||
| cd backend | ||
| go mod download | ||
| go mod tidy | ||
|
|
||
| # Frontend | ||
| cd frontend | ||
| npm install | ||
| ``` | ||
|
|
||
| ### Session Already Exists | ||
|
|
||
| If the tmux session already exists, the script will attach to it. To start fresh: | ||
|
|
||
| ```bash | ||
| # Kill the existing session | ||
| tmux kill-session -t ccsync | ||
|
|
||
| # Run setup again | ||
| ./development/setup.sh | ||
| ``` | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [CCSync Documentation](https://its-me-abhishek.github.io/ccsync-docs/) | ||
| - [Taskwarrior Documentation](https://taskwarrior.org/docs/) | ||
| - [Tmux Cheat Sheet](https://tmuxcheatsheet.com/) | ||
| - [Contributing Guidelines](../CONTRIBUTING.md) | ||
|
|
||
| ## Notes | ||
|
|
||
| - The setup script automatically installs dependencies if they're not present | ||
| - All services run in development mode with hot-reloading enabled | ||
| - Logs from all services are visible in their respective tmux panes | ||
| - The script validates environment files before starting services | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/bin/bash | ||
|
|
||
| SESSION="ccsync" | ||
| ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
|
|
||
| echo "CCSync Development Setup" | ||
| echo "========================" | ||
| echo "" | ||
|
|
||
| if ! command -v tmux &> /dev/null; then | ||
| echo "Error: tmux is not installed." | ||
| echo "Install it using:" | ||
| echo " - macOS: brew install tmux" | ||
| echo " - Ubuntu/Debian: sudo apt-get install tmux" | ||
| echo " - Fedora: sudo dnf install tmux" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v go &> /dev/null; then | ||
| echo "Error: Go is not installed." | ||
| echo "Download from: https://go.dev/doc/install" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v node &> /dev/null; then | ||
| echo "Error: Node.js is not installed." | ||
| echo "Download from: https://nodejs.org/" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v npm &> /dev/null; then | ||
| echo "Error: npm is not installed." | ||
| echo "It should come with Node.js: https://nodejs.org/" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! docker info &> /dev/null; then | ||
| echo "Error: Docker is not running." | ||
| echo "Please start Docker Desktop or the Docker daemon." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "$ROOT_DIR/backend/.env" ]; then | ||
| echo "Error: backend/.env file not found." | ||
| echo "Please create it with required environment variables." | ||
| echo "See development/README.md or https://its-me-abhishek.github.io/ccsync-docs/ for details." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "$ROOT_DIR/frontend/.env" ]; then | ||
| echo "Error: frontend/.env file not found." | ||
| echo "Please create it with required environment variables." | ||
| echo "See development/README.md or https://its-me-abhishek.github.io/ccsync-docs/ for details." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Installing dependencies..." | ||
| echo "" | ||
|
|
||
| cd "$ROOT_DIR/backend" | ||
| if [ ! -d "vendor" ] && [ ! -f "go.sum" ]; then | ||
| echo "Downloading Go modules..." | ||
| go mod download | ||
| go mod tidy | ||
| fi | ||
|
|
||
| cd "$ROOT_DIR/frontend" | ||
| if [ ! -d "node_modules" ]; then | ||
| echo "Installing npm packages..." | ||
| npm install | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Starting services in tmux session '$SESSION'..." | ||
| echo "" | ||
|
|
||
| tmux has-session -t $SESSION 2>/dev/null | ||
|
|
||
| if [ $? == 0 ]; then | ||
| echo "Session '$SESSION' already exists." | ||
| echo "Attaching to existing session..." | ||
| tmux attach -t $SESSION | ||
| exit 0 | ||
| fi | ||
|
|
||
| tmux new-session -d -s $SESSION -n "ccsync" | ||
|
|
||
| tmux send-keys -t $SESSION:0 "cd $ROOT_DIR/backend && echo 'Starting Backend...' && go run ." C-m | ||
|
|
||
| tmux split-window -h -t $SESSION:0 | ||
| tmux send-keys -t $SESSION:0.1 "cd $ROOT_DIR/frontend && echo 'Starting Frontend...' && npm run dev" C-m | ||
|
|
||
| tmux split-window -v -t $SESSION:0.1 | ||
| tmux send-keys -t $SESSION:0.2 "cd $ROOT_DIR && echo 'Starting Sync Server...' && docker-compose up syncserver" C-m | ||
|
|
||
| tmux select-layout -t $SESSION:0 main-vertical | ||
|
|
||
| echo "Services started successfully!" | ||
| echo "" | ||
| echo "Tmux commands:" | ||
| echo " - Detach: Ctrl+b then d" | ||
| echo " - Reattach: tmux attach -t $SESSION" | ||
| echo " - Kill session: tmux kill-session -t $SESSION" | ||
| echo "" | ||
| echo "Attaching to session..." | ||
| sleep 1 | ||
|
|
||
| tmux attach -t $SESSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
|
|
||
| SESSION="ccsync" | ||
|
|
||
| echo "Stopping CCSync development environment..." | ||
| echo "" | ||
|
|
||
| tmux has-session -t $SESSION 2>/dev/null | ||
|
|
||
| if [ $? != 0 ]; then | ||
| echo "Session '$SESSION' does not exist or is not running." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Killing tmux session '$SESSION'..." | ||
| tmux kill-session -t $SESSION | ||
|
|
||
| echo "Stopping Docker containers..." | ||
| docker-compose down | ||
|
|
||
| echo "" | ||
| echo "CCSync development environment stopped successfully." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been Syncserver instead, docker-compose up syncserver