sudo: sorry, you must have a tty to run sudo
This message is found it error log file. This could be due to requiretty being enabled in visudo by default. Reference here.
If this is the case, it is better to apply workaround in the init script, instead of altering visudo default configuration.