0

I do have service looking like this:

[Unit]
Description=API environment service

[Service]
WorkingDirectory=/var/www/api
ExecStart=/var/www/api/api
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=apache
Environment=ASPNETCORE_ENVIRONMENT=Production 

[Install]

Service works but every time I copy new files to that folder through ftp I need to run sudo chmod +x /var/www/api/api to make that file executable and then do sudo systemctl restart api.service

My question is is it possible to somehow add line at top of this service which will make this file executable if it is not so i only need to run restart command?

  • Your FTP client should already make it executable for you. – Michael Hampton Jul 21 '21 at 23:56
  • Nope it doesnt. I tried deleting everything, adding files again and restarting service it does not work. Then i make it executable and restart service and it does indeed work – Aleksa Ristic Jul 22 '21 at 00:10
  • I can solve only part of your problem - do not run the executable directly, but run a bash script which runs it. Therefore even you need to retype `chmod +x /var/www/api/api` you do not need to restart the service. – George Y Jul 22 '21 at 02:53
  • Following @GeorgeY . For example, if `api` binary is `python` replace `ExecStart=/var/www/api/api` by `ExecStart=/bin/bash -c "/usr/bin/python3 /var/www/api/api"` so you don't need to have it executable. – Tk421 Jul 22 '21 at 09:53

0 Answers0