Need to create my own local service, my own local server - how I can do that?
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need to create my own local service, my own local server - how I can do that?
Just as in title. Service, server, custom application - common infrastructure - I just don't want to run again and again the same application to gather information. Worse - to create hard encoded user interface I think is wrong solution. Small service would allow me to use different user interfaces - depending on my needs. So where to begin? Literature to read, code to hack? How small? I would say tiny. Esentially is there recipe how to create own service and server? I would greatly appreciate help. I am not aware to hack a code - no matter C, Perl, Python, Awk, shell scripting - maybe except C++ and similar huge languages.
Here is one idea. A cron job could be used to run your application over and over again to gather information and maybe store it in a file or database. You can use a web server with CGI, bash or anything else to display that information.
Thank's but I need to create first this service and server. So well defined way for application to communicate with server and to obtain required information. Kind of communication protocol but of course not something - I am imagining that server is listening umm say on socket - there is request - then eg. it sends back name of named fifo to establish one-way connection - and through that fifo sends requested information - but it needs to fork if there are several request - but the truth these are only my blind guesses - maybe this maybe - server by itself is very simple it looks for information on internet and preprocess it before sending back. I could put this hard coded into larger program - but I want to avoid this. If I would need new functionality instead of to rewrite, to extend old program it would be simpler to create new. At the end I would have a bunch of small apps. So the first step is: how to write your own server?
First, what kind of data are you trying to collect?
What are you trying to collect from?
Not to stiffle your creativity but do not reinvent the wheel. Once you figure out what you are collecting data from, then you can select a data format that is compatible and if it is going over a network, the protocol to use for the data collection.
A server to display the data will depend on the display format. If it is graphs and pie charts, I suggest something like rrdtool. This can be called from a cgi script and a web page can be dynamically generated to display the data in near real time.
Thanks I compiled the example from the first link. It works. As it was in comments I changed "/" to "/tmp". I read man(3) about daemon function but I have no idea how to call daemon() instead of what is in this example.
Thanks. Don't know what actually to think about daemonizing scripts - they are being executed by interpreter - so it is rather interpreter demonize itself - I will try later on example in Python but I suspect in processes list there will be something like '3314 user users python /home/user/my-daemon.py'. But of course I need to run this the first.
Thanks - starting from chapter 15 - custom app needs to communicate somehow with server.
Edit: At this moment with my knowledge supposedly I myself don't know clear what I want. Service - one requests something - clean a carpet - and it is done. To separate part of job independent on custom action - customer can add functionality to its own application. But all these application rely on the same service. People often ask: why your app does not do this or that? This was I realized that instead of trying to build app which would satisfy all possible wishes - it is better to provide service and let others create their own custom apps.
A somewhat complicated example of what I think you want to accomplish is gpsd. It reads GPS receiver data and provides it to clients over TCP networking. It has an API developed for several different programming languages.
You will need to do the same thing i.e. collect the information and then provide it to the clients using a defined protocol. Write your service so that it can be run as a regular application for troubleshooting purposes and not as daemon.
Maybe xinetd is something to look into when you want a service up on demand.
Although in that case xinetd would be up all the time instead of the service
Good suggestion. xinetd would be the daemon process and when it detects traffic on the desired port starts your application and pipes the incoming data to it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.