PHP shell_exec似乎失败了

I'm trying to write a script for a client to reset the mysql service whenever they need to. (they're using a janky CMS/eccomerce that sometimes messes with the database in weird ways and it needs to be reset)

This issue is that shell_exec doesn't seem to be working, the var_dump statement outputs NULL and the mysql server is not reset.

The snippet of code that does the resetting looks like this

$output =  shell_exec('/usr/bin/sudo /bin/restartmysql');
var_dump($output);

/bin/restartmysql is a binary wrapper for restarting the database, the source for it looks like this

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(char argc, char** argv) {
  setuid(0);
  system("/usr/sbin/service mysql restart");
  return 1;
}

I've doubled checked and shell_exec is not disabled in my php.ini, also www-data has correct permissions to execute restartmysql

here's the sudoers snippet

www-data       LOCAL=NOPASSWD:/bin/restartmysql

Update:

When redirecting to stderr it showed that it was attempting to ask for a password with sudo, which was actually not needed because of the way the permissions are on the binary wrapper. However when removing sudo from the command I still receive this error.

string(106) "/usr/sbin/service: 127: /usr/sbin/service: stop: not found
/usr/sbin/service: 128: exec: start: not found
"