[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-824545790 Cool. Thank you. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-823984771 Okay -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-823151812 ![image](https://user-images.githubusercontent.com/41498427/115378133-dfdc2600-a1ed-11eb-9486-83c3b0c8b429.png) new commands -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-822607540 >how about ./manager-api start and ./manager-api stop, when run ./manager-api start and the service is not installed, install it ? Okay then, I will take care of checking and installing(if required) for `./manager-api start`. And yes, actual commands instead of flags would look nice, thanks for that. Regarding the commands I think, we could provide install, remove and status too. - ./manager-api start - ./manager-api stop - ./manager-api status (option to check service status from the binary itself without depending on os specific service manager) - ./manager-api remove (would be helpful deleting service test file without manually navigating to the filesystem) - ./manager-api install (reinstalling the service, if the binary location needs to be changed in future, service must be reinstalled. Also in newer releases if we introduce extra flags, that should be passed as arguments for ExecStart of the service unit file i.e. need reinstallation) what do you think :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-822182633 > don't see the update? @bisakhmondal Updated :) Fully tested on Linux (ubuntu 20.04). I don't have macOS or windows. Please let me know if it is working or not when you have some time. ![image](https://user-images.githubusercontent.com/41498427/115186411-49313b80-a0ff-11eb-9d30-1a0465769435.png) cc @nic-chen, @membphis, @tokers, @starsz -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-821070687 Hii all, I am updating this PR with `takama/daemon` as @nic-chen suggested on the discussion thread. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-816757811 Absolutely. No problem :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-816462583 Hii @membphis, @nic-chen, I have checked and found these few packages that look good and have cross-platform support. On the way, found a lot of packages that run as a bg process using `Exec()` and are obviously not immune to SIGHUP when its controlling terminal sends it. 1. https://github.com/takama/daemon [supports linux, win, osx] (easy APIs, uses OS-specific service manager, under the hood, no nasty multiple forks) 2. https://github.com/sevlyar/go-daemon [Doesn't supports windows till now] 3. https://github.com/kardianos/service [more stars :)] Let me know which one you like :) If you ask me, I'd say going with option 1 is a good choice. It's really simple, and no overhead of keeping the package up-to-date as it's kind of an overlay on top of the os specific system managers. Tested with a gin server ```go package main import ( "fmt" "github.com/gin-gonic/gin" "github.com/takama/daemon" "net/http" "os" "os/signal" "syscall" "time" ) type Service struct { daemon.Daemon } func (service* Service) Manage() (string, error){ if len(os.Args) > 1 { command := os.Args[1] switch command { case "install": return service.Install() case "remove": return service.Remove() case "start": return service.Start() case "stop": return service.Stop() case "status": return service.Status() default: return "Usage: myservice install | remove | start | stop | status", nil } } r := gin.Default() fmt.Println("id: ",os.Getpid()) fmt.Println("ppid: ", os.Getppid()) r.GET("/", func(g *gin.Context) { g.JSON(http.StatusOK, gin.H{ "message": "Server running successfully", }) }) go r.Run(":8080") sig := make(chan os.Signal, 1) signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL) sis := <- sig fmt.Println("signal received: ", sis.String()) time.Sleep(2*time.Second) fmt.Println("Shutted down") return "Closed", nil } func main() { srv, err := daemon.New("my-gin-app", "my gin app", daemon.SystemDaemon) if err !=nil{ panic(err) } service := &Service{srv} status, err := service.Manage() if err != nil{ panic(err) } fmt.Println(status) } ``` commands ```shell go build main.go sudo ./main install sudo ./main start ``` ![image](https://user-images.githubusercontent.com/41498427/114141510-4da36a80-992f-11eb-9ead-6293446ec2cd.png) Thanks😄 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-809953964 Ok, I'll post it here :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-808851381 > @bisakhmondal > I think we could use a library to automate, instead of writing a configuration for each platform. What do you think? Totally agree with you :+1: . A few days back I found https://github.com/kardianos/service. It seems it's gonna serve our purpose (I haven't tested it though). What do you think? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-808663653 ping @nic-chen for review when you have time. ps. reverted all the changes made to manger-api back. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-808154939 ya sure :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix-dashboard] bisakhmondal commented on pull request #1667: feat: run manager-api as a systemd daemon/service
bisakhmondal commented on pull request #1667: URL: https://github.com/apache/apisix-dashboard/pull/1667#issuecomment-806073350 Backend CLI Test is failing for changing `log.Infof("The Manager API server receive %s and start shutting down", sig.String())` to `log.Infof("The Manager API server receives %s and starts acting up", sig.String())` hehe :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org