Lorenz Brun | fc5dbc6 | 2020-05-28 12:18:07 +0200 | [diff] [blame] | 1 | // Copyright 2020 The Monogon Project Authors. |
| 2 | // |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "context" |
Lorenz Brun | 52f7f29 | 2020-06-24 16:42:02 +0200 | [diff] [blame^] | 21 | "log" |
Lorenz Brun | fc5dbc6 | 2020-05-28 12:18:07 +0200 | [diff] [blame] | 22 | "os" |
| 23 | "os/signal" |
| 24 | "syscall" |
| 25 | |
| 26 | "git.monogon.dev/source/nexantic.git/core/internal/launch" |
| 27 | ) |
| 28 | |
| 29 | func main() { |
| 30 | sigs := make(chan os.Signal, 1) |
| 31 | signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) |
| 32 | ctx, cancel := context.WithCancel(context.Background()) |
| 33 | go func() { |
| 34 | <-sigs |
| 35 | cancel() |
| 36 | }() |
| 37 | if err := launch.Launch(ctx, launch.Options{Ports: launch.IdentityPortMap()}); err != nil { |
| 38 | if err == ctx.Err() { |
| 39 | return |
| 40 | } |
Lorenz Brun | 52f7f29 | 2020-06-24 16:42:02 +0200 | [diff] [blame^] | 41 | log.Fatalf("Failed to execute: %v\n", err) |
Lorenz Brun | fc5dbc6 | 2020-05-28 12:18:07 +0200 | [diff] [blame] | 42 | } |
| 43 | } |