Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ service file.
Since these paths are specific to a machine, it's not recommended to check the
service files into your respository.

You can generate and install the service file to the system with the following
You can generate and link the service file to the system with the following
command:

```bash
$ lapis systemd service development --install
$ lapis systemd service development --link
```

You can then start your service:
Expand Down Expand Up @@ -106,4 +106,3 @@ You can access the systemd journal with the `lapis.systemd.journal` module:
journal = require("lapis.systemd.journal")
journal.log("hello world!", {priority = 5})
```

7 changes: 3 additions & 4 deletions lapis/cmd/actions/systemd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local parse_flags
parse_flags = require("lapis.cmd.util").parse_flags
return {
name = "systemd",
usage = "systemd service [environment] [--install]",
usage = "systemd service [environment] [--link]",
help = "create systemd service files",
function(self, flags, command, environment)
environment = environment or default_environment()
Expand All @@ -15,10 +15,9 @@ return {
render_service_file = require("lapis.systemd.service").render_service_file
local contents, file, dir = render_service_file(config)
path.write_file(file, contents)
if flags.install then
if flags.link then
local src = path.shell_escape(tostring(dir) .. "/" .. tostring(file))
local dest = path.shell_escape("/usr/lib/systemd/system/" .. tostring(file))
path.exec("sudo cp '" .. tostring(src) .. "' '" .. tostring(dest) .. "'")
path.exec("sudo systemctl link '" .. tostring(src) .. "'")
return path.exec("sudo systemctl daemon-reload")
end
end
Expand Down
7 changes: 3 additions & 4 deletions lapis/cmd/actions/systemd.moon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import parse_flags from require "lapis.cmd.util"

{
name: "systemd"
usage: "systemd service [environment] [--install]"
usage: "systemd service [environment] [--link]"
help: "create systemd service files"

(flags, command, environment) =>
Expand All @@ -20,10 +20,9 @@ import parse_flags from require "lapis.cmd.util"

path.write_file file, contents

if flags.install
if flags.link
src = path.shell_escape "#{dir}/#{file}"
dest = path.shell_escape "/usr/lib/systemd/system/#{file}"

path.exec "sudo cp '#{src}' '#{dest}'"
path.exec "sudo systemctl link '#{src}'"
path.exec "sudo systemctl daemon-reload"
}