A
A
Artem Prokhorov2021-11-29 22:15:26
go
Artem Prokhorov, 2021-11-29 22:15:26

Is it possible to somehow achieve the inclusion / stop / restart of the golang server through the console?

Yuzayu Gin. When the server starts, but now you can turn it off only through Ctr + c. Plus, when it's enabled, the terminal is essentially locked. Well, that is, I can open the second one, but I'm not used to this at all. Is this normal? This is not how it will not affect the placement of the project? The same example of shutting down the server in the Gin dock . But this is very cluttered, and it only works through code. go run main.go

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
uvelichitel, 2021-11-29
@kotcich

The question is not entirely clear. Why don't you actually like Ctr+c Shutdown from the docks? If you want the server not to block the console just like that and start it
$ myserver &
with this application, you can

  • to extinguish a separate endpoint in the rest api. That is, put the extinguishing Handler ondomain.com/admin/shutdown
  • or provide a call with a flag myserver --quitthat will communicate with an already running instance via net / rpc or unix pipe or unix socket or the same http and call the extinguishing procedure
  • or write systemd units in the usual way

D
Drno, 2021-11-29
@Drno

Doesn't he know how to work as a service?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question