-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating 'wings service-install' command #136
Open
mundotv789123
wants to merge
4
commits into
pterodactyl:develop
Choose a base branch
from
mundotv789123:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c47324b
Creating 'wings service-install' command
mundotv789123 8654e63
Adding 'systemctl daemon-reload' command after service is installed.
mundotv789123 84ec566
fix errors references on messages.
mundotv789123 93c5999
Merge branch 'pterodactyl:develop' into develop
mundotv789123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/apex/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
serviceFile = "/etc/systemd/system/wings.service" | ||
serviceContent = `[Unit] | ||
Description=Pterodactyl Wings Daemon | ||
After=docker.service | ||
Requires=docker.service | ||
PartOf=docker.service | ||
|
||
[Service] | ||
User=root | ||
WorkingDirectory=/etc/pterodactyl | ||
LimitNOFILE=4096 | ||
PIDFile=/var/run/wings/daemon.pid | ||
ExecStart=/usr/local/bin/wings | ||
Restart=on-failure | ||
StartLimitInterval=180 | ||
StartLimitBurst=30 | ||
RestartSec=5s | ||
|
||
[Install] | ||
WantedBy=multi-user.target` | ||
serviceCmd = &cobra.Command{ | ||
Use: "service-install", | ||
Short: "Use to install wings.service automatically", | ||
Run: installService, | ||
} | ||
) | ||
|
||
func installService(cmd *cobra.Command, args []string) { | ||
if _, err := os.Stat(serviceFile); err == nil { | ||
log.WithField("error", "service file exists").Fatal("service aready installed") | ||
return | ||
} | ||
|
||
f, cf_err := os.Create(serviceFile) | ||
|
||
if cf_err != nil { | ||
log.WithField("error", cf_err).Fatal("error while creating service file") | ||
return | ||
} | ||
|
||
content := []byte(serviceContent) | ||
|
||
_, wf_err := f.Write(content) | ||
|
||
if wf_err != nil { | ||
log.WithField("error", wf_err).Fatal("error while write service file") | ||
return | ||
} | ||
|
||
command := exec.Command("systemctl", "enable", "--now", serviceFile) | ||
cmd_err := command.Start() | ||
|
||
if cmd_err != nil { | ||
log.WithField("error", wf_err).Fatal("error while enabling service") | ||
return | ||
} | ||
fmt.Println("service created success!") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing a
systemctl daemon-reload
after adding the systemd files. You need to reload after creating the file before you can start the serviceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i did really forget that, thanks.