How to create a daemon in centos 7 in lua?

Good afternoon.
There is a lua script, which connects to the server in a loop until the connection is waiting for the event and is already doing the necessary processing.
Something like this
#!/usr/local/bin/lua

local con = Connetct(url, login, pass);

if con:connected() then
#processing
end


In order to run this script as a daemon using systemd. Was this config
[Unit]
Description=lvCallCenter
After=mysql.service
Requires=mysql.service

[Service]
Type=forking
PIDFile=pid
WorkingDirectory=dir

User=leadvertex
Group=leadvertex

Environment=NOT=production

OOMScoreAdjust=-1000

ExecStart=/usr/local/bin/lua script.lua
Restart=always
TimeoutSec=300

[Install]
WantedBy=multi-user.target

Run it a bit wrong, as we would like, i.e. after you run the command systemctl start myunit nothing happens, no output, all start and you have to press ctrl+c to cancel.
But the demon appears in the processes and everything works.

But I would like to do to it is normally run.
Most likely the problem is in the output streams, I tried to not override did not help. Also I think that the lua script somehow should answer systemd that it has started and is running.
Please help to resolve this issue. Thank you in advance for your help.
July 2nd 19 at 17:03
2 answers
July 2nd 19 at 17:05
Solution
You have specified "Type=forking", which is used for services, which themselves run in the background. Your script does not. So remove the "Type=forking", or replace it with a default value of "Type=simple".
Thanks for help - Fred_Durg commented on July 2nd 19 at 17:08
July 2nd 19 at 17:07
Not an expert in systemd and tembolee in lua. But "launch daemons" I've always helped such a crutch as a screen :)
you can of course through the screen, but it still spike - Fred_Durg commented on July 2nd 19 at 17:10

Find more questions by tags CentOSLinuxLua