I'm trying to run some services on a ubuntu server using process() (from Symfony\Component\Process\Process)
$process = new Process(['systemctl', '--user', 'start', $serviceName]);
try {
$process->mustRun();
}
catch (ProcessFailedException $ex) {
Log::alert($ex->getMessage());
}
but I'm getting the following error:
The command "'systemctl' '--user' 'start' 'some_service_name.service'" failed.
Exit Code: 1(General error)
Working directory: /
Output:
Error Output:
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
Any help would be much appreciated!