aws-greengrass / aws-greengrass-nucleus

The Greengrass nucleus component provides functionality for device side orchestration of deployments and lifecycle management for execution of Greengrass components and applications. This includes features such as starting, stopping, and monitoring execution of components and apps, interprocess communication server for communication between components, component installation and configuration management.
Apache License 2.0
110 stars 45 forks source link

(nucleus): Unable to set up Nucleus as a system service on Windows #1301

Closed vladas-tamosaitis-tfs closed 2 years ago

vladas-tamosaitis-tfs commented 2 years ago

Describe the bug During greengrass install, when I set any custom path in Droot that includes spaces, e.g. C:\Program Files (x86)\greengrass\v2, the Install process goes fine but afterward I get the log message Unable to set up Nucleus as a system service.

In greengrass.log I see

2022-09-11T08:48:19.545Z [ERROR] (Copier) com.aws.greengrass.util.orchestration.WinswUtils: winsw-setup. {stderr='C:\Program' is not recognized as an internal or external command,, command=C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.exe install C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.xml}
2022-09-11T08:48:19.545Z [ERROR] (Copier) com.aws.greengrass.util.orchestration.WinswUtils: winsw-setup. {stderr=operable program or batch file., command=C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.exe install C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.xml}
2022-09-11T08:48:19.545Z [ERROR] (main) com.aws.greengrass.util.orchestration.WinswUtils: winsw-setup. Failed to set up Windows service. {}
java.io.IOException: Command C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.exe install C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.xml failed
    at com.aws.greengrass.util.orchestration.SystemServiceUtils.runCommand(SystemServiceUtils.java:51)
    at com.aws.greengrass.util.orchestration.WinswUtils.setupSystemService(WinswUtils.java:57)
    at com.aws.greengrass.easysetup.GreengrassSetup.performSetup(GreengrassSetup.java:328)
    at com.aws.greengrass.easysetup.GreengrassSetup.main(GreengrassSetup.java:269)

To Reproduce

java "-Droot=C:\Program Files (x86)\greengrass\v2" "-Dlog.store=FILE" -jar "Downloads\GreengrassInstaller\lib\Greengrass.jar" --aws-region eu-west-1 --thing-name MyGreengrassCore --thing-group-name MyGreengrassCoreGroup --component-default-user ggc_user --provision true --setup-system-service true

Expected behavior Path to executable and path to the XML config require quotation marks when installing system service (https://docs.microsoft.com/en-us/troubleshoot/windows-server/deployment/filenames-with-spaces-require-quotation-mark)

"C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.exe" install "C:\Program Files (x86)\greengrass\v2\alts\current\distro\bin\greengrass.xml"

Actual behavior After greengrass is installed, no system service is present

$ sc query "greengrass"

[SC] EnumQueryServicesStatus:OpenService FAILED 1060:

The specified service does not exist as an installed service.

Environment

Additional context I need to install greengrass to some custom path different from c:\greengrass\v2 because when we install it on a customer's PC, there is a risk for it to be removed by administrator or some other personnel according to some security policies and procedures

MikeDombo commented 2 years ago

Hello @vladas-tamosaitis-tfs,

Thank you for the detailed report. Can you install Greengrass into some other path which has no spaces? C:\greengrass\v2 would be preferred, but you do not need to use that path, as long as the path doesn't have spaces.

vladas-tamosaitis-tfs commented 2 years ago

Hello @vladas-tamosaitis-tfs,

Thank you for the detailed report. Can you install Greengrass into some other path which has no spaces? C:\greengrass\v2 would be preferred, but you do not need to use that path, as long as the path doesn't have spaces.

Yeah, the path w/o spaces works fine, as well as c:\greengrass\v2. I see the PR for this issue was merged, will wait for the next nucleus release then. Thank you for the fast issue resolve!