R
R
Roman Rakzin2016-01-16 12:11:25
go
Roman Rakzin, 2016-01-16 12:11:25

How to pass values ​​to another program in Golang?

There is a running golang exe file on a remote computer. At the time of the update, I need to send a command to this process from another program (on the same computer), "close", after which it closes and a new exe is copied and then it starts. How can I pass the value to the program and then open the file?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abcyu, 2016-01-16
@TwoRS

The correct option is to package the program as a service/daemon using this https://github.com/takama/daemon or similar packages.
Extinguish it with service/daemon controls. There are even ready-made systems that do exactly this - they stop the program, update it, start it.
Pure - how to send a command: the simplest TCP / IP, and even http is more convenient. For Go, this is easy to do with the net/http package. By catching an HTTP GET (which is easy to do with curl, wget, or embed in your update utility) to a specific URL you write, the HttpHandler should exit the program gracefully. There are many illustrations, examples, and documentation for the net/http package.

O
Oleg Tsilyurik, 2016-01-16
@Olej

Your question has nothing to do with Go, or with programs in general, or any "passing value to a program"...
These are questions about remote access, you need to: 1). stop the process, 2). copy the file, 3). run the program, all 3 positions are independent of each other.
Such things are simply done using the SSH protocol.
You do not write what OS you have ... but judging by the .exe - Windows.

V
Vitaly Filinkov, 2016-01-16
@vitfil

You yourself answered your own question: "I need to give a command to this process." That's right: you need to issue a command to this process. OS tools, for example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question