summaryrefslogtreecommitdiffhomepage
path: root/src/go/unit/nxt_go_lib.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-12-13 18:12:13 +0300
committerMax Romanov <max.romanov@nginx.com>2017-12-13 18:12:13 +0300
commit799cff5f3e226d8a82a767714c59815939a989dd (patch)
treea844660aba1423de68726f55a83cdbe6a7d49d82 /src/go/unit/nxt_go_lib.c
parentb680e944d65d56e92919287247bd47e13ad030e9 (diff)
downloadunit-799cff5f3e226d8a82a767714c59815939a989dd.tar.gz
unit-799cff5f3e226d8a82a767714c59815939a989dd.tar.bz2
Introducing Unit version check in Go package.
To communicate with the Go program, Unit setup environment variable named NXT_GO_PORTS with value contains Unit version, stream id to confirm application is started, and Unit ports information. Go Unit package parses this string and compares runtime version with compile time version. In case of parse error or version mismatch, ListenAndServe() returns with the error.
Diffstat (limited to '')
-rw-r--r--src/go/unit/nxt_go_lib.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/go/unit/nxt_go_lib.c b/src/go/unit/nxt_go_lib.c
index 84d64c0e..4c6b9ac2 100644
--- a/src/go/unit/nxt_go_lib.c
+++ b/src/go/unit/nxt_go_lib.c
@@ -112,18 +112,11 @@ nxt_go_request_done(nxt_go_request_t r)
void
-nxt_go_ready()
+nxt_go_ready(uint32_t stream)
{
- char *go_stream;
- nxt_port_msg_t port_msg;
+ nxt_port_msg_t port_msg;
- go_stream = getenv("NXT_GO_STREAM");
-
- if (go_stream == NULL) {
- return;
- }
-
- port_msg.stream = atol(go_stream);
+ port_msg.stream = stream;
port_msg.pid = getpid();
port_msg.reply_port = 0;
port_msg.type = _NXT_PORT_MSG_PROCESS_READY;
@@ -141,3 +134,10 @@ nxt_go_process_port_msg(uintptr_t buf, size_t buf_len, uintptr_t oob, size_t oob
{
return nxt_go_port_on_read((void *) buf, buf_len, (void *) oob, oob_len);
}
+
+
+const char *
+nxt_go_version()
+{
+ return NXT_VERSION;
+}