LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-03-2018, 02:14 AM   #1
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 572

Rep: Reputation: 38
Any framework to support equivalence of systemd.socket


Does anyone know if there are any frameworks/programs around that will allow the .socket file technique from systemd to be used on Slack.

I'm fairly used to making applications that just use .service files run, as that's usually just the case of creating the right shell script to run the program.

But the whole .socket concept used to then start a .service file is a whole different beast.

Or (maybe) just some hints on the sequence of events in setting up the socket, the listener, and the handoff between the client (which I assume writes to the socket) and the server which is then started as a result.

Cheers.
 
Old 12-03-2018, 02:57 AM   #2
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 4,519

Rep: Reputation: Disabled
https://www.freedesktop.org/software...md.socket.html

IMHO the whole thing has sense only when used with systemd, trying to port that logic to the Slackware init scripts will mean, at least, rewriting all of them from scratch, taking away muuuch more time than it's worth and with an end result that won't be even close to the goal (I strongly doubt something like that will work with a shell-based init system)...
always remember the "if it's not broken don't fix it!"™️ golden rule!

Last edited by ponce; 12-03-2018 at 03:16 AM.
 
Old 12-03-2018, 04:03 AM   #3
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 572

Original Poster
Rep: Reputation: 38
I'd already read up on what the .socket files are. And I'm not trying to re-write any init scripts.

I'm trying to run a (compiled code only) application that uses a single .service file to run the system daemon (as root) and a .socket file to create a file-based socket to listen for commands from the user-land part sent to the daemon.

Cheers.
 
Old 12-03-2018, 05:34 AM   #4
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys for decades while testing others to keep up
Posts: 2,016

Rep: Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911
Won't Docker do that?
 
Old 12-03-2018, 06:16 AM   #5
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 4,519

Rep: Reputation: Disabled
Quote:
Originally Posted by MQMan View Post
I'd already read up on what the .socket files are. And I'm not trying to re-write any init scripts.

I'm trying to run a (compiled code only) application that uses a single .service file to run the system daemon (as root) and a .socket file to create a file-based socket to listen for commands from the user-land part sent to the daemon.
*.service files on systemd OSes are handled by the init system: IMHO, if you are trying to implement something similar that handles them in a non-systemd OS you have to do it at that level...

if you need all of this just for an application, running it in a container, like enorbet suggested, could be enough.

another alternative could be to implement what is written on the service file in another shell script written from scratch, but in that case, the shell script doesn't necessarily need to do everything described in the service files, behaving like systemd does (creating sockets, forking, etc., obviously depending on the application): I'll paste below, as an example, the httpd service file and /etc/rc.d/rc.httpd from Slackware
Code:
[Unit]
Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/httpd/httpd.pid
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl graceful-stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target
Code:
#!/bin/sh
#
# /etc/rc.d/rc.httpd
#
# Start/stop/restart/graceful[ly restart]/graceful[ly]-stop
# the Apache (httpd) web server.
#
# To make Apache start automatically at boot, make this
# file executable:  chmod 755 /etc/rc.d/rc.httpd
#
# For information on these options, "man apachectl".

case "$1" in
  'start')
    /usr/sbin/apachectl -k start
  ;;
  'stop')
    /usr/sbin/apachectl -k stop
    pkill -f /usr/sbin/httpd
    # Remove both old and new .pid locations:
    rm -f /var/run/httpd.pid /var/run/httpd/httpd.pid
  ;;
  'force-restart')
    # Because sometimes restarting through apachectl just doesn't do the trick...
    /usr/sbin/apachectl -k stop
    pkill -f /usr/sbin/httpd
    # Remove both old and new .pid locations:
    rm -f /var/run/httpd.pid /var/run/httpd/httpd.pid
    /usr/sbin/apachectl -k start
  ;;
  'restart')
    /usr/sbin/apachectl -k restart
  ;;
  'graceful')
    /usr/sbin/apachectl -k graceful
  ;;
  'graceful-stop')
    /usr/sbin/apachectl -k graceful-stop
  ;;
  *)
    echo "Usage: $0 {start|stop|restart|graceful|graceful-stop}"
  ;;
esac

Last edited by ponce; 12-03-2018 at 06:42 AM.
 
Old 12-03-2018, 11:39 AM   #6
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 572

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by ponce View Post
another alternative could be to implement what is written on the service file in another shell script written from scratch
I'd already indicated I know how to do that.
Quote:
Originally Posted by MQMan View Post
I'm fairly used to making applications that just use .service files run, as that's usually just the case of creating the right shell script to run the program.
Quote:
Originally Posted by ponce View Post
but in that case, the shell script doesn't necessarily need to do everything described in the service files, behaving like systemd does (creating sockets, forking, etc., obviously depending on the application)
This is the part I'm looking for assistance on, because that's an important part of the application and won't run without it.
Quote:
Originally Posted by enorbet View Post
Won't Docker do that?
The way the application works, is that the user-space application, which can be run by any user, needs the daemon to perform (some) actions that need root access on it's behalf, via a file-based socket. Can that daemon, running in Docker, perform those actions for any user-space application.

Cheers.
 
Old 12-03-2018, 11:42 AM   #7
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 4,519

Rep: Reputation: Disabled
it depends on what the daemon with root access does.
it's hard to try to understand what you need based on generic behaviours: maybe if you point at the application of which you are speaking of somebody could have a look at its specific behaviour.
if you already have analyzed its specific behaviour, maybe trying to explain it in detail (what you expect in detail from the user space application, what specific actions the daemon performs, etc.) could help also.

also, as this doesn't seem to have much to do with Slackware in particular, I suppose you might have a much better help in the programming section.

Last edited by ponce; 12-03-2018 at 11:57 AM.
 
Old 12-04-2018, 12:18 AM   #8
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,094

Rep: Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472
Quote:
Originally Posted by MQMan View Post
I'd already read up on what the .socket files are. And I'm not trying to re-write any init scripts.

I'm trying to run a (compiled code only) application that uses a single .service file to run the system daemon (as root) and a .socket file to create a file-based socket to listen for commands from the user-land part sent to the daemon.

Cheers.
Use DBus to talk to your daemon (which is always running). The protocol's there already.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify UDP receive socket buffer size for an open socket (not at system level, but socket level) barz_83_LQ Linux - Networking 2 11-27-2017 08:56 PM
Connecting client socket to server socket only once in socket programming srinietrx Programming 5 08-20-2017 12:53 PM
Discussion: is it possible to combine video framework and media framework in kernel? happycrab Linux - Kernel 1 09-06-2014 04:51 AM
suse 9.2 install software online / FC2 yum equivalence friendship7 SUSE / openSUSE 3 01-31-2005 06:50 AM
bash equivalence of tcsh "alias em "emacs \!:1 &""? rgiggs Slackware 3 07-29-2004 03:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration