Update README, use tighter permissions
This commit is contained in:
parent
b66adef4f6
commit
ae7f311c8e
19
README.md
19
README.md
@ -9,6 +9,7 @@
|
|||||||
func main() {
|
func main() {
|
||||||
appName := "coolapp"
|
appName := "coolapp"
|
||||||
if deploy {
|
if deploy {
|
||||||
|
// error checking ignored for this example
|
||||||
unit, _ := unitard.NewUnit(appName)
|
unit, _ := unitard.NewUnit(appName)
|
||||||
unit.Deploy()
|
unit.Deploy()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
@ -18,16 +19,20 @@
|
|||||||
|
|
||||||
## What it does
|
## What it does
|
||||||
|
|
||||||
`Deploy()` automatically creates a systemd unit file, reloads the systemd daemon
|
This package provides a simple interface to automatically creating and enabling a
|
||||||
so it can use it, enables the unit (so it starts on boot) and starts the service
|
systemd "user unit" service, as part of your single-binary deployment.
|
||||||
|
|
||||||
|
The `Deploy()` function creates the systemd unit file, reloads the systemd daemon
|
||||||
|
so it reads it, enables the unit (to start on boot) and starts the service
|
||||||
running.
|
running.
|
||||||
|
|
||||||
This means you can have a single binary deployment. Copy your executable to "somewhere"
|
Copy your executable to "somewhere" on your target system, run it with `-deploy`
|
||||||
on your target system, run it with `-deploy` (or however you have enabled the call to `Deploy()`)
|
(or however you have enabled the call to `Deploy()`) and your application starts
|
||||||
and your application starts running in the background, and will restart on boot.
|
running in the background and will restart on boot.
|
||||||
|
|
||||||
There is also an `Undeploy()` func, which you should of course
|
There is also an `Undeploy()` func, which you should of course provide as an option
|
||||||
provide as an option to your users. It stops the running service, removes the unit file and restarts systemd.
|
to your users. It stops the running service, removes the unit file and reloads the
|
||||||
|
systemd daemon.
|
||||||
|
|
||||||
## What's with the name?
|
## What's with the name?
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ func (u *Unit) setupEnvironment() error {
|
|||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
err = os.MkdirAll(unitFileDirectory, 0777)
|
err = os.MkdirAll(unitFileDirectory, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot create the user systemd path '%s': %s", unitFileDirectory, err)
|
return fmt.Errorf("cannot create the user systemd path '%s': %s", unitFileDirectory, err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user