github.com/eth-easl/loader@v0.0.0-20230908084258-8a37e1d94279/server/trace-func-go/trace_func.go (about)

     1  /*
     2   * MIT License
     3   *
     4   * Copyright (c) 2023 EASL and the vHive community
     5   *
     6   * Permission is hereby granted, free of charge, to any person obtaining a copy
     7   * of this software and associated documentation files (the "Software"), to deal
     8   * in the Software without restriction, including without limitation the rights
     9   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    10   * copies of the Software, and to permit persons to whom the Software is
    11   * furnished to do so, subject to the following conditions:
    12   *
    13   * The above copyright notice and this permission notice shall be included in all
    14   * copies or substantial portions of the Software.
    15   *
    16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    22   * SOFTWARE.
    23   */
    24  
    25  package main
    26  
    27  import (
    28  	"flag"
    29  	"github.com/eth-easl/loader/pkg/workload/standard"
    30  	log "github.com/sirupsen/logrus"
    31  	"os"
    32  	"strconv"
    33  )
    34  
    35  var (
    36  	zipkin = flag.String("zipkin", "http://zipkin.zipkin:9411/api/v2/spans", "zipkin url")
    37  )
    38  
    39  func main() {
    40  	// For containers - port 80; for Firecracker - 50051.
    41  	var serverPort = 80
    42  	var functionType standard.FunctionType
    43  
    44  	if len(os.Args) > 1 {
    45  		serverPort, _ = strconv.Atoi(os.Args[1])
    46  
    47  		switch os.Args[2] {
    48  		case "EMPTY":
    49  			functionType = standard.EmptyFunction
    50  		default:
    51  			functionType = standard.TraceFunction
    52  		}
    53  
    54  		log.Infof("Port: %d\n", serverPort)
    55  		log.Infof("Function type: %s\n", os.Args[2])
    56  	}
    57  
    58  	standard.StartGRPCServer("", serverPort, functionType, *zipkin)
    59  }