User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
gentoo:locald [2024/07/30 09:36] willygentoo:locald [2024/07/30 09:40] (current) willy
Line 32: Line 32:
 The other way is to use local.d service leveraging a specific script with symlinks: the idea is to use one script for most of the services, and just create a symlink to the start and stop scripts themselves.  The other way is to use local.d service leveraging a specific script with symlinks: the idea is to use one script for most of the services, and just create a symlink to the start and stop scripts themselves. 
  
-Assuming you have a service called **myservice**, which is a podman container, run as //myuser// user, all you need to do it: +For simple non-containerized service called **mynormalservice** running as user **myotheruser**:
-<code bash> +
-cd /etc/local.d +
-ln -s _servicer.sh 50-myservice-myuser-podman.start  +
-ln -s _servicer.sh 50-myservice-myuser-podman.stop +
-</code> +
- +
-and that's it. This will automatically create the **/var/run/myservice.pid** file for service-monitoring, and allow proper start and stop of the service. This will require the usual //docker-compose.yml// file in the //myuser// folder. +
- +
-Similarly, for a simple non-containerized service:+
 <code bash> <code bash>
 cd /etc/local.d cd /etc/local.d
Line 70: Line 61:
 #  - user is the user the service will run as. Can be omitted, in this case use two "--", and user=service #  - user is the user the service will run as. Can be omitted, in this case use two "--", and user=service
 #  - type is one of: #  - type is one of:
-#        - podman: the service is a podman-compose based containeration 
 #        - script: the service is managed by a script ($user_home/myservice_start.sh or $user_home/myservice.sh, and $user_home/myservice_stop.sh (optional)) #        - script: the service is managed by a script ($user_home/myservice_start.sh or $user_home/myservice.sh, and $user_home/myservice_stop.sh (optional))
 #        - service: the service command is specified inside a service_${service}_start file in the user home folder #        - service: the service command is specified inside a service_${service}_start file in the user home folder
Line 101: Line 91:
         } && chown -R ${USER} "${LOG_PATH}/${SERVICE}"         } && chown -R ${USER} "${LOG_PATH}/${SERVICE}"
         extra_opts=(-1 "${LOG_PATH}/${SERVICE}/${SERVICE}.out.log" -2 "${LOG_PATH}/${SERVICE}/${SERVICE}.err.log")         extra_opts=(-1 "${LOG_PATH}/${SERVICE}/${SERVICE}.out.log" -2 "${LOG_PATH}/${SERVICE}/${SERVICE}.err.log")
-        if [ "${TYPE}" = "podman"+        if [ "${TYPE}" = "script" ]
-        then +
-                COMMAND="$(which podman)" +
-                ARGUMENTS=(compose up) +
-                echo "          ... ensuring nat table is loaded ..." >> ${actions_logs} +
-                iptables -L -t nat &> /dev/null +
-                echo "          ... creating '${SERVICE}-net' ..." >> ${actions_logs} +
-                podman network create ${SERVICE}-net &> /dev/null +
-                echo "          ... running a 'podman compose down' just in case ..." >> ${actions_logs} +
-                su - "${USER}" -c "$(which podman) compose down" &> /dev/null +
-        elif [ "${TYPE}" = "script" ]+
         then         then
                 echo "          ... checking for start scripts ..." >> ${actions_logs}                 echo "          ... checking for start scripts ..." >> ${actions_logs}
Line 134: Line 114:
 then then
         extra_opts=()         extra_opts=()
-        if [ "${TYPE}" = "podman"+        if [ "${TYPE}" = "script" ]
-        then +
-                echo "          ... running 'podman compose down' ..." >> ${actions_logs} +
-                su - "${USER}" -c "$(which podman) compose down" &> /dev/null +
-                action=(--stop "${SERVICE}"+
-        elif [ "${TYPE}" = "script" ]+
         then         then
                 echo "          ... checking for stop script ..." >> ${actions_logs}                 echo "          ... checking for stop script ..." >> ${actions_logs}
Line 176: Line 151:
 **User name:** which user shall run the service. Can be omitted (just leave two "--") and in this case a user with the same name as the service will be used. The user __must__ exist. **User name:** which user shall run the service. Can be omitted (just leave two "--") and in this case a user with the same name as the service will be used. The user __must__ exist.
  
-**Service type:** can be //podman//, //service// or //script//: +**Service type:** can be //service// or //script//:
-  - //podman//: run **podman compose up (or down)** as the user+
   - //service//: source the file $HOME/service_<service>_start and execute COMMAND ARGUMENTS (see example below)   - //service//: source the file $HOME/service_<service>_start and execute COMMAND ARGUMENTS (see example below)
   - //script//: will run $HOME/<service>_start.sh / $HOME/<service>_stop.sh   - //script//: will run $HOME/<service>_start.sh / $HOME/<service>_stop.sh

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information