gorush

repository·master·Indexed 27 days ago

https://github.com/appleboy/gorush

A push notification micro server written in Go using the Gin framework. It serves as a centralized gateway to send notifications to iOS (APNS), Android (FCM), and Huawei (HMS) devices via a REST API or gRPC. Features include support for Live Activities, topic-based messaging, Prometheus metrics, and deployment options via Docker, Docker Compose, and Kubernetes.

Tokens
8.1K
Snippets
23
Records
45
Agent score
94%

What's inside gorush

  1. Install gorush via Install Script

    master

    The recommended way to install gorush is using the official install script, which detects your OS and architecture, downloads the latest version, installs it to ~/.gorush/bin, and adds it to your PATH.

    Customization Options:

    • Specific Version: Set VERSION=X.Y.Z before running the script.
    • Custom Directory: Set INSTALL_DIR=/path/to/dir before running the script.
    • Skip SSL Verification: Set INSECURE=1 (not recommended).
  2. Deploy Gorush on AWS Lambda

    master

    To deploy Gorush as an AWS Lambda function, build the Linux Lambda binary, package it as a ZIP, and update the function code via the AWS CLI.

    # Build Lambda binary
    git clone https://github.com/appleboy/gorush.git
    cd gorush
    make build_linux_lambda
    
    # Create deployment package
    zip deployment.zip release/linux/lambda/gorush
    
    # Deploy with AWS CLI
    aws lambda update-function-code \
      --function-name gorush \
      --zip-file fileb://deployment.zip
  3. Run gorush with Docker

    master

    You can run gorush using Docker. To run with a custom configuration file, mount your local config.yml to the container's expected path.

    # Run directly
    docker run --rm -p 8088:8088 appleboy/gorush
    
    # With custom config
    docker run --rm -p 8088:8088 -v $(pwd)/config.yml:/home/gorush/config.yml appleboy/gorush
  4. Install gorush via Package Managers or Go

    master

    You can install gorush using Homebrew, Go, or by building from source.

    Homebrew (macOS/Linux):

    brew tap appleboy/tap
    brew install gorush

    Go Install:

    # Latest stable version
    go install github.com/appleboy/gorush@latest
    
    # Development version
    go install github.com/appleboy/gorush@master

    Build from Source: Requires Go 1.25+ and Git.

    git clone https://github.com/appleboy/gorush.git
    cd gorush
    make build
  5. Quick Start with gorush

    master

    You can get gorush running in three steps: download the binary, start the server, and send a test notification via curl.

    1. Download the binary: Use wget to fetch the specific version for your architecture and make it executable.
    2. Start the server: Run the binary. By default, it listens on port 8088.
    3. Send a notification: Use a POST request to /api/push with a JSON payload containing a notifications array. Each notification requires tokens (an array), platform (integer code), title, and message.

    Platform Codes:

    • 1: iOS (APNS)
    • 2: Android (FCM)
    • 3: Huawei (HMS)
    # 1. Download the latest binary
    wget https://github.com/appleboy/gorush/releases/download/v1.18.9/gorush-1.18.9-linux-amd64 -O gorush
    chmod +x gorush
    
    # 2. Start the server (default port 8088)
    ./gorush
    
    # 3. Send your first notification
    curl -X POST http://localhost:8088/api/push \
      -H "Content-Type: application/json" \
      -d '{
        "notifications": [{
          "tokens": ["your_device_token"],
          "platform": 2,
          "title": "Hello World",
          "message": "Your first notification!"
        }]
      }'
  6. Deploy Gorush using Docker

    master

    You can run Gorush using Docker with default configurations, custom configurations via a mounted volume, or in detached mode.

    # Run with default config
    docker run --rm -p 8088:8088 appleboy/gorush
    
    # Run with custom config
    docker run --rm -p 8088:8088 \
      -v $(pwd)/config.yml:/home/gorush/config.yml \
      appleboy/gorush
    
    # Run in background
    docker run -d --name gorush -p 8088:8088 appleboy/gorush
  7. Start the gorush server

    master

    You can start the gorush server using the default configuration (listening on port 8088), by specifying a custom configuration file, or by overriding specific options via CLI flags.

    # Use default config (port 8088)
    ./gorush
    
    # Use custom config file
    ./gorush -c config.yml
    
    # Set specific options
    ./gorush -p 9000 -c config.yml
  8. Generate Node.js gRPC code from proto files

    master

    Use protoc to generate the necessary JavaScript and gRPC code from the gorush.proto definition. This command requires grpc-tools to be installed globally and assumes you are running the command from the root of the gorush repository.

    cd $GOPATH/src/github.com/appleboy/gorush
    protoc -I rpc/proto rpc/proto/gorush.proto --js_out=import_style=commonjs,binary:rpc/example/node/ --grpc_out=rpc/example/node/ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin`
  9. Configure and start the gorush service

    master

    Before starting the service, you must create a configuration directory at /etc/gorush and place a configuration file (e.g., config.yml) inside it. Once configured, you can manage the service using the /etc/init.d/gorush script.

    # Create configuration directory and copy config
    mkdir -p /etc/gorush
    cp config/testdata/config.yml /etc/gorush/
    
    # Start the service
    /etc/init.d/gorush start
  10. Deploy Gorush on Netlify Functions

    master

    Deploy Gorush to Netlify Functions by configuring netlify.toml to build the Lambda binary and redirect traffic to the function.

    # netlify.toml
    [build]
    command = "make build_linux_lambda"
    functions = "release/linux/lambda"
    
    [build.environment]
    GO_VERSION = "1.24"
    
    [[redirects]]
    from = "/*"
    status = 200
    to = "/.netlify/functions/gorush/:splat"