forked from gofiber/recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (32 loc) · 778 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 🚀 Fiber is an Express inspired web framework written in Go with 💖
// 📌 API Documentation: https://docs.gofiber.io
// 📝 Github Repository: https://github.com/gofiber/fiber
package main
import (
"fmt"
"log"
"os"
"github.com/gofiber/fiber/v2"
)
func main() {
// Print current process
if fiber.IsChild() {
fmt.Printf("[%d] Child\n", os.Getppid())
} else {
fmt.Printf("[%d] Master\n", os.Getppid())
}
// Fiber instance
app := fiber.New(fiber.Config{
Prefork: true,
})
// Routes
app.Get("/", hello)
// Start server
log.Fatal(app.Listen(":3000"))
// Run the following command to see all processes sharing port 3000:
// sudo lsof -i -P -n | grep LISTEN
}
// Handler
func hello(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
}