Running 1.6.3 as a service

Hello,

I’ve managed to successfully deploy vault 1.6.3 open source, but my problem now lies in that I need vault to run as a service, to ensure that I can run it and then log off the machine. ANd of course so that I can enable it so that it starts up when my machine reboots. I"m failing epically. Can someone point me in the right direction?

Thanks in advance

Here’s my config file, stored at /vault_files/config.hcl

storage “raft” {
path = “./vault/data”
node_id = “node1”
}

listener “tcp” {
address = “127.0.0.1:8200”
tls_disable = “true”
}

api_addr = “http://127.0.0.1:8200
cluster_addr = “https://127.0.0.1:8201
ui = true

The vault.service file I epically failed at creating properly:

[Unit]
Description=vault service
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/vault_files/config.hcl

[Service]
EnvironmentFile=-/etc/sysconfig/vault
Environment=GOMAXPROCS=2
Restart=on-failure
ExecStart=vault server -config=/vault_files/config.hcl
StandardOutput=/logs/vault/output.log
StandardError=/logs/vault/error.log
LimitMEMLOCK=infinity
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

The error when trying to start vault.service:

Mar 01 15:34:35 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:13] Failed to parse o…log
Mar 01 15:34:35 vault-server-001 systemd[1]: vault.service lacks both ExecStart= and ExecStop= settin…ing.
Mar 01 15:36:10 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:11] Executable path i…hcl
Mar 01 15:36:10 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:12] Failed to parse o…log
Mar 01 15:36:10 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:13] Failed to parse o…log
Mar 01 15:36:10 vault-server-001 systemd[1]: vault.service lacks both ExecStart= and ExecStop= settin…ing.
Mar 01 15:36:23 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:11] Executable path i…hcl
Mar 01 15:36:23 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:12] Failed to parse o…log
Mar 01 15:36:23 vault-server-001 systemd[1]: [/etc/systemd/system/vault.service:13] Failed to parse o…log
Mar 01 15:36:23 vault-server-001 systemd[1]: vault.service lacks both ExecStart= and ExecStop= settin…ing.

Updated service file, new error:

[Unit]
Description=vault service
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/vault_files/config.hcl

[Service]
EnvironmentFile=-/etc/sysconfig/vault
Environment=GOMAXPROCS=2
Restart=on-failure
ExecStart=/vault server -config=/vault_files/config.hcl
StandardOutput=/logs/vault/output.log
StandardError=/logs/vault/error.log
LimitMEMLOCK=infinity
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
ExecStop=

[Install]
WantedBy=multi-user.target

Running a systemctl start vault.service now returns no errors, but checking the status:

systemctl status vault.service
● vault.service - vault service
Loaded: loaded (/etc/systemd/system/vault.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Mon 2021-03-01 16:16:30 UTC; 10s ago
Process: 2017 ExecStart=/vault server -config=/vault_files/config.hcl (code=exited, status=1/FAILURE)
Main PID: 2017 (code=exited, status=1/FAILURE)

Mar 01 16:16:30 vault-server-001 systemd[1]: vault.service: main process exited, code=exited, status=1/FAILURE
Mar 01 16:16:30 vault-server-001 systemd[1]: Unit vault.service entered failed state.
Mar 01 16:16:30 vault-server-001 systemd[1]: vault.service failed.
Mar 01 16:16:30 vault-server-001 systemd[1]: vault.service holdoff time over, scheduling restart.
Mar 01 16:16:30 vault-server-001 systemd[1]: Stopped vault service.
Mar 01 16:16:30 vault-server-001 systemd[1]: start request repeated too quickly for vault.service
Mar 01 16:16:30 vault-server-001 systemd[1]: Failed to start vault service.
Mar 01 16:16:30 vault-server-001 systemd[1]: Unit vault.service entered failed state.
Mar 01 16:16:30 vault-server-001 systemd[1]: vault.service failed.
[duanewolford@vault-server-001 /]$ sudo vim /etc/systemd/system/vault.service

Maybe start from Hashicorp’s Vault recommented Linux service definition, make sure it works, then customize it to your needs?

1 Like