Skip to content

Commit

Permalink
Update systemd-setup.sh to install system.json (#2651)
Browse files Browse the repository at this point in the history
Right now a system.json file is not created when setting up systemd through the setup-systemd.sh script. Therefore, users aren't letting their nodes know that the algod process will be managed with systemd. This change modifies the systemd configuration file to create the system.json file in the data directory.
  • Loading branch information
bricerisingalgorand authored Jul 29, 2021
1 parent d1425f0 commit 0d4b5bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/goal/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const (
errorNodeRunning = "Node must be stopped before writing APIToken"
errorNodeFailGenToken = "Cannot generate API token: %s"
errorNodeCreation = "Error during node creation: %v"
errorNodeManagedBySystemd = "This node is managed by systemd, you must run the following command to make your desired state change to your node:\n\nsystemctl %s algorand.service"
errorNodeManagedBySystemd = "This node is using systemd and should be managed with systemctl. For additional information refer to https://developer.algorand.org/docs/run-a-node/setup/install/#installing-algod-as-a-systemd-service"
errorKill = "Cannot kill node: %s"
errorCloningNode = "Error cloning the node: %s"
infoNodeCloned = "Node cloned successfully to: %s"
Expand Down
6 changes: 3 additions & 3 deletions cmd/goal/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var startCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
reportErrorf(errorNodeManagedBySystemd, "start")
reportErrorf(errorNodeManagedBySystemd)
}

nc := nodecontrol.MakeNodeController(binDir, dataDir)
Expand Down Expand Up @@ -237,7 +237,7 @@ var stopCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
reportErrorf(errorNodeManagedBySystemd, "stop")
reportErrorf(errorNodeManagedBySystemd)
}

nc := nodecontrol.MakeNodeController(binDir, dataDir)
Expand Down Expand Up @@ -268,7 +268,7 @@ var restartCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
reportErrorf(errorNodeManagedBySystemd, "restart")
reportErrorf(errorNodeManagedBySystemd)
}

nc := nodecontrol.MakeNodeController(binDir, dataDir)
Expand Down
1 change: 1 addition & 0 deletions installer/algorand@.service.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ After=network.target
AssertPathExists=%I

[Service]
ExecStartPre=bash -c "[[ ! -f %I/system.json ]] && echo '{\"shared_server\":true,\"systemd_managed\":true}' > %I/system.json || :"
ExecStart=@@BINDIR@@/algod -d %I
User=@@USER@@
Group=@@GROUP@@
Expand Down

0 comments on commit 0d4b5bb

Please sign in to comment.