Automatic download & Installation with --systemd throws error

Report a Dgraph Bug

When I try to download and install dgraph via curl https://get.dgraph.io -sSf | bash -s -- --systemd it throws the following error:

Failed to start dgraph-alpha.service: Unit dgraph-alpha.service has a bad unit file setting.
See system logs and 'systemctl status dgraph-alpha.service' for details.
There was some problem while installing Dgraph. Please share the output of this script with us on https://discuss.dgraph.io so that we can resolve the issue for you.

Running the suggested command:

systemctl status dgraph-alpha.service
‚óŹ dgraph-alpha.service - dgraph.io Alpha instance
     Loaded: bad-setting (Reason: Unit dgraph-alpha.service has a bad unit file setting.)
     Active: inactive (dead)

systemd[1]: /etc/systemd/system/dgraph-alpha.service:10: Executable "c" not found in path "/usr/local/sb>
systemd[1]: dgraph-alpha.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.

I guess something is wrong with the systemd file generation. The installation without systemd works.

What version of Dgraph are you using?

Dgraph Version

Dgraph version   : v21.03.1
Dgraph codename  : rocket-1
Dgraph SHA-256   : a00b73d583a720aa787171e43b4cb4dbbf75b38e522f66c9943ab2f0263007fe
Commit SHA-1     : ea1cb5f35
Commit timestamp : 2021-06-17 20:38:11 +0530
Branch           : HEAD
Go version       : go1.16.2
jemalloc enabled : true

For Dgraph official documentation, visit https://dgraph.io/docs.
For discussions about Dgraph     , visit https://discuss.dgraph.io.
For fully-managed Dgraph Cloud   , visit https://dgraph.io/cloud.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2021 Dgraph Labs, Inc.

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

Steps to reproduce the issue (command/config used to run Dgraph).

curl https://get.dgraph.io -sSf | bash -s -- --systemd

Expected behaviour and actual result.

Can fix this issue by changing the dgraph-alpha.service file to the following:
Tried to fix with the following settings, but still causes alpha to crash

[Unit]
Description=dgraph.io Alpha instance
Wants=network.target
After=network.target dgraph-zero.service
Requires=dgraph-zero.service

[Service]
Type=simple
WorkingDirectory=/var/lib/dgraph
ExecStart=dgraph alpha --cache size-mb=2048 -p /var/lib/dgraph/p -w /var/lib/dgraph/w
Restart=on-failure
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target

Similarly, dgraph-zero.service needs these settings:

[Unit]
Description=dgraph.io Zero instance
Wants=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=/var/lib/dgraph
ExecStart=dgraph zero --wal /var/lib/dgraph/zw
Restart=on-failure
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target
RequiredBy=dgraph-alpha.service

Fixed it by installing dgraph without system.d and creating the systemd service files manually:

Create service for alpha: /etc/systemd/system/dgraph-alpha.service:

[Unit]
Description=dgraph.io Alpha instance
Wants=network.target
After=network.target
Requires=dgraph-zero.service

[Service]
Type=simple
WorkingDirectory=/var/lib/dgraph
ExecStart=dgraph alpha -p /var/lib/dgraph/p -w /var/lib/dgraph/w
Restart=on-failure
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target

Create file for zero: /etc/systemd/system/dgraph-zero.service:

[Unit]
Description=dgraph.io Zero instance
Wants=network.target
After=network.target

[Service]
Type=simple
WorkingDirectory=/var/lib/dgraph
ExecStart=dgraph zero --wal /var/lib/dgraph/zw
Restart=on-failure
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target
RequiredBy=dgraph-alpha.service