Valeriy Solovyov
Valeriy Solovyov

Reputation: 5648

How to implement CLI client to golang daemon?

I have a linux daemon with http api which I have wrote on golang. At start he initialize variables and all time when I ask api - he is answer. Init is hard operation: read many config's, add many object's etc.

My problem that if main process die I can't use http api ;). My code isn't perfect and sometimes he stack or die, or user's disable linux service. But I still need some low level functionality to work.

If I try to implement all functions of web api at cli: his start will be very slow and hard for system. But I have more problem if implementation will be separated between CLI & web api: inconsistent. For example: I can start inside web api create && at same time inside CLI - delete all. I must implement lock function to prevent this. (I think write code at this side isn't good)

I don't use database server (and don't need). Maybe I can store inside files or use some shared memory?

My question is how can I share object's data between golang daemon and CLI-client?

Upvotes: 2

Views: 1131

Answers (1)

user918176
user918176

Reputation: 1800

Go has a built-in RPC system for easy communication between Go processes. You could also take a look at 0mq, or using D-Bus.

Upvotes: 1

Related Questions