W
W
wargych2020-08-27 02:43:29
linux
wargych, 2020-08-27 02:43:29

How to implement background application control via console?

The question is the following:
there is a small application with websockets on go. I thought about adding the ability to ban / unban users to it.
It seems logical to just do it through standard input - output in the console, but since the application is launched in the background via systemd, but I can’t catch up yet, how can I switch to console application management in this case)
Flags seem to have nothing to do with it either, because are responsible for configuring the application at startup and do not work with already launched ones.
In the end, it needs to work like, for example, mongoDB - you enter mongo and the console is transferred to application management.
Where to dig to implement this? Programming is a hobby for me, I still don’t understand what to google in the direction.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
index0h, 2020-08-27
@wargych

There are several options:
1. Through stdin, in linux, as a rule, you can reach it in /proc/PROCESS_ID/fd/0
2. Listen in a separate socket file
3. Send a separate network request
4. You can look towards d-bus
.. .

S
Saboteur, 2020-08-27
@saboteur_kiev

In the end, it needs to work like, for example, mongoDB - you enter mongo and the console is transferred to application management.

Well, it's COMPLETELY not so simple.
there is a separate mongo server application and there is a separate mongo client application that connects to the server by port. Moreover, it is connected not even to the console, but to a network socket, and you can connect from another computer.
So it is with you - the background application listens to the socket, accepts commands and executes them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question