Socat and systemd -
I need to run a script, which is running one of the many sockets, running the script properly from the command line Now, what I need now is that this script is being run as a service.
I have this script:
#! / Usr / bin / env sh set -e TTY = $ {AQM_TTY: - / dev / ttyUSB0} / reg_seion / DESTINOS = (http://127.0.0.1) LOG_DIR =. / Logs-aqm mkdir -p "$ {LOG_DIR}" ### Added ### Allo $$> /var/run/colector.pid socat -b 115200 $ {TTY}, resonance = 0, crnl - | Grep - line-buffered "^ RS" | During posting; For Destino, make $ {DESTINOS [@]}; Do wget --post-data = "$ (echo" $ {post} "| tr -d" \ n ")" \ -O / dev / null \ --no-verbose \ - background \ --append-output = "$ {LOG_DIR} / $ {destino //}} log" \ "$ {destino} / reg_sesion / create" has been echo "$ {post}" | TE-A "$ {LOG_DIR} / Aquim.log" and service file:
[unit] Description = colter [service] type = simple PIDFile = / var / run / colector.pid user = root group = root # ExecStart = / root / socat.sh ExecStart = / bin / sh -c '/root/socat.sh' [install] WantedBy = multi-User .target When I start the service, the process begins and ends soon.
Any ideas? Remove PidFile =
And see if it works.
PIDFile = is primarily for type = forking , where your startup program is sub-process, you can see the process (system) PIDFile). In the case of type = simple , with your long-running service, the system will create sub-process to start your service, so it knows what the PID is.
Comments
Post a Comment