By ijunaid8989
This is as simple upstart job which we wrote for starting our application but I am unable to find any good solution to make it for systemD… If I may create a simple Start and Post Exec command base file, It just gave me errors and nothing work…
I have only hurdles with those basic values as from start to setgid root? how can we write it in SystemD service?
description "evercam_media"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
limit nofile 1000000 1000000
respawn
chdir /
setuid root
setgid root
env HOME=/home/root
env LANG=en_US.UTF-8
env LANGUAGE=en_US:en
env LS_ALL=en_US.UTF-8
env ERL_MAX_PORTS=10240
exec watch -n1 '/usr/local/bin/run_evercam_media.sh'
post-stop exec sudo pkill beam
Any help will be wonderful, i have been struggling so long on this
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This should be a good starting point:
[Unit]
Description=evercam media
After=network-online.target
[Service]
Restart=on-failure
User=root
Group=root
Environment=HOME=/home/root LANG=en_US.UTF-8 LANGUAGE=en_US:en LS_ALL=en_US.UTF-8 ERL_MAX_PORTS=10240
WorkingDirectory=/
ExecStart=/usr/bin/watch -n1 '/usr/local/bin/run_evercam_media.sh'
ExecStopPost=/bin/pkill beam
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target
The main difference is that systemd requires absolute paths. I noticed that the service is running as root. I would recommend looking into having it run as a regular user unless absolutely necessary :)
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.