ubuntu-service 1.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -15
- package/README.md +129 -117
- package/bin/index.js +8 -8
- package/package.json +50 -47
- package/src/cli.js +2 -2
- package/src/index.js +3 -3
- package/src/{v1 → v2}/actions.js +49 -58
- package/src/{v1 → v2}/cli.js +245 -245
- package/src/{v1 → v2}/detector.js +195 -194
- package/src/v2/index.js +11 -0
- package/src/{v1 → v2}/parser.js +113 -113
- package/src/{v1 → v2}/systemctl.js +147 -147
- package/src/v3/cli.js +126 -0
- package/src/v3/index.js +5 -0
- package/src/v3/service.js +175 -0
- package/src/v1/index.js +0 -55
package/LICENSE
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 KeshavSoft
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeshavSoft
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,117 +1,129 @@
|
|
|
1
|
-
# ubuntu-service
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/ISC)
|
|
5
|
-
[](https://www.npmjs.com/package/ubuntu-service)
|
|
4
|
+
[](https://opensource.org/licenses/ISC)
|
|
5
|
+
[](https://keshavsoft.github.io/ubuntu-service-docs/service/)
|
|
6
|
+
[](https://keshavsoft.github.io/ubuntu-service-docs/)
|
|
7
|
+
[](https://github.com/keshavsoft)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
> **Context-aware single service manager for Ubuntu VPS.**
|
|
11
|
+
> Automatically identifies the systemd service associated with your current working directory (`process.cwd()`), inspects its status, restarts it, and displays its logs. Zero memory needed—run right after `git pull`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 🌐 Documentation & Suite Links
|
|
16
|
+
|
|
17
|
+
- **Dedicated Documentation:** [https://keshavsoft.github.io/ubuntu-service-docs/service/](https://keshavsoft.github.io/ubuntu-service-docs/service/)
|
|
18
|
+
- **Full Suite Hub:** [https://keshavsoft.github.io/ubuntu-service-docs/](https://keshavsoft.github.io/ubuntu-service-docs/)
|
|
19
|
+
- **All 8 Repositories in Family:** [https://keshavsoft.github.io/ubuntu-service-docs/repos/](https://keshavsoft.github.io/ubuntu-service-docs/repos/)
|
|
20
|
+
- **Sub-packages:**
|
|
21
|
+
- `ubuntu-service-detect`: [npm](https://www.npmjs.com/package/ubuntu-service-detect) | [docs](https://keshavsoft.github.io/ubuntu-service-docs/detect/) | [repo](https://github.com/keshavsoft/ubuntu-service-detect)
|
|
22
|
+
- `ubuntu-service-restart`: [npm](https://www.npmjs.com/package/ubuntu-service-restart) | [docs](https://keshavsoft.github.io/ubuntu-service-docs/restart/) | [repo](https://github.com/keshavsoft/ubuntu-service-restart)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🎯 The Philosophy: Singular vs. Plural
|
|
27
|
+
|
|
28
|
+
| Repository | Focus | Scope | Question Answered |
|
|
29
|
+
| :--- | :--- | :--- | :--- |
|
|
30
|
+
| **`ubuntu-services`** *(Plural)* | Fleet / Inventory | All services on the OS | *"What is everything running on my Ubuntu VPS? Are there broken folders?"* |
|
|
31
|
+
| **`ubuntu-service`** *(Singular)* | Atomic / Current App | Single service for current directory | *"What service runs THIS folder, and let me restart only this service right now."* |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 💡 The Everyday VPS Problem
|
|
36
|
+
|
|
37
|
+
When deploying code on an Ubuntu server:
|
|
38
|
+
```bash
|
|
39
|
+
root@server6358:~/KeshavSoft/appointment-notifier# git pull
|
|
40
|
+
Updating cced23f..34bc3e5
|
|
41
|
+
Fast-forward
|
|
42
|
+
...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Now you need to restart the application. But:
|
|
46
|
+
* *What is the exact systemd unit name for this directory?*
|
|
47
|
+
* Is it `appointment.service`? `appointment-notifier.service`? `appointment.keshavsoft.com.service`?
|
|
48
|
+
* Instead of grepping `/etc/systemd/system/` or rebooting the server:
|
|
49
|
+
|
|
50
|
+
Simply run:
|
|
51
|
+
```bash
|
|
52
|
+
us restart
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## ⚡ Quick Start
|
|
58
|
+
|
|
59
|
+
Run directly with zero installation via `npx`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Stand in any project directory on your Ubuntu VPS
|
|
63
|
+
cd /root/KeshavSoft/appointment-notifier
|
|
64
|
+
|
|
65
|
+
# 1. Inspect the service running this directory
|
|
66
|
+
npx ubuntu-service
|
|
67
|
+
# Or with short alias:
|
|
68
|
+
us
|
|
69
|
+
|
|
70
|
+
# 2. Restart ONLY this service
|
|
71
|
+
us restart
|
|
72
|
+
|
|
73
|
+
# 3. View live systemd logs
|
|
74
|
+
us logs -n 50
|
|
75
|
+
|
|
76
|
+
# 4. Output only the unit name (e.g. for scripts or CI)
|
|
77
|
+
us name
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 📖 CLI Commands
|
|
83
|
+
|
|
84
|
+
| Command | Description |
|
|
85
|
+
| :--- | :--- |
|
|
86
|
+
| `us` / `npx ubuntu-service` | Shows service card: unit name, state, PID, memory, port, working directory |
|
|
87
|
+
| `us restart` | Restarts only the service attached to the current directory and verifies status |
|
|
88
|
+
| `us status` | Detailed status inspection for the current service |
|
|
89
|
+
| `us logs [-n <count>]` | Fetches live `journalctl` logs for this specific service |
|
|
90
|
+
| `us name` | Prints only the unit name (e.g. `appointment.keshavsoft.com.service`) |
|
|
91
|
+
| `us port` | Prints only the detected port (e.g. `3000`) |
|
|
92
|
+
|
|
93
|
+
### Flags & Options
|
|
94
|
+
|
|
95
|
+
* `--dir <path>`: Target a specific folder instead of `process.cwd()`
|
|
96
|
+
* `--systemd-dir <path>`: Custom systemd directory (useful for testing)
|
|
97
|
+
* `-n, --lines <count>`: Number of log lines to retrieve (default: 25)
|
|
98
|
+
* `--json`: Output machine-readable JSON
|
|
99
|
+
* `-h, --help`: Display help screen
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 🏗️ Architecture
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
ubuntu-service/
|
|
107
|
+
├── bin/
|
|
108
|
+
│ └── index.js # Executable entrypoint (`ubuntu-service`, `us`)
|
|
109
|
+
├── src/
|
|
110
|
+
│ ├── index.js # Orchestrator (delegates to latest v1)
|
|
111
|
+
│ ├── cli.js # CLI Orchestrator
|
|
112
|
+
│ └── v1/
|
|
113
|
+
│ ├── index.js # Public API exports
|
|
114
|
+
│ ├── detector.js # Context detection (CWD to systemd unit mapping)
|
|
115
|
+
│ ├── parser.js # Systemd .service INI & port parser
|
|
116
|
+
│ ├── systemctl.js # Native systemctl & journalctl execution
|
|
117
|
+
│ ├── actions.js # Business actions (inspect, restart, logs)
|
|
118
|
+
│ └── cli.js # Terminal UI & formatting
|
|
119
|
+
├── test/ # Automated test suite (node --test)
|
|
120
|
+
├── docs/ # GitHub Pages portal & live terminal simulator
|
|
121
|
+
├── package.json # Whitelisted files: ["bin", "src"], zero dependencies
|
|
122
|
+
└── LICENSE # ISC License
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 🛡️ License
|
|
128
|
+
|
|
129
|
+
ISC License — [KeshavSoft](https://github.com/keshavsoft)
|
package/bin/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { runCli } from "../src/cli.js";
|
|
4
|
-
|
|
5
|
-
const exitCode = runCli(process.argv.slice(2));
|
|
6
|
-
if (typeof exitCode === "number") {
|
|
7
|
-
process.exitCode = exitCode;
|
|
8
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runCli } from "../src/cli.js";
|
|
4
|
+
|
|
5
|
+
const exitCode = runCli(process.argv.slice(2));
|
|
6
|
+
if (typeof exitCode === "number") {
|
|
7
|
+
process.exitCode = exitCode;
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ubuntu-service",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./src/index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./src/index.js"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"ubuntu"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"url": "https://github.com/keshavsoft/ubuntu-service
|
|
42
|
-
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "ubuntu-service",
|
|
3
|
+
"version": "3.1.1",
|
|
4
|
+
"description": "Single-domain systemd service inspector for an Ubuntu VPS (v3 requires an explicit domain parameter).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"ubuntu-service": "bin/index.js",
|
|
12
|
+
"us": "bin/index.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "node bin/index.js",
|
|
20
|
+
"cli": "node bin/index.js",
|
|
21
|
+
"test": "node --test"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"ubuntu-service-detect": "^1.0.0",
|
|
25
|
+
"ubuntu-service-restart": "^1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"ubuntu",
|
|
29
|
+
"systemd",
|
|
30
|
+
"service",
|
|
31
|
+
"vps",
|
|
32
|
+
"process",
|
|
33
|
+
"restart",
|
|
34
|
+
"cwd",
|
|
35
|
+
"caddy"
|
|
36
|
+
],
|
|
37
|
+
"author": "KeshavSoft",
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/keshavsoft/ubuntu-service.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/keshavsoft/ubuntu-service/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://keshavsoft.github.io/ubuntu-service/",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Orchestrator: delegates CLI execution directly to latest version (
|
|
2
|
-
export { runCli, printHelp } from "./
|
|
1
|
+
// Orchestrator: delegates CLI execution directly to latest version (v3)
|
|
2
|
+
export { runCli, printHelp } from "./v3/cli.js";
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// Orchestrator: delegates directly to latest version (
|
|
2
|
-
export * from "./
|
|
3
|
-
export { default } from "./
|
|
1
|
+
// Orchestrator: delegates directly to latest version (v3)
|
|
2
|
+
export * from "./v3/index.js";
|
|
3
|
+
export { default } from "./v3/index.js";
|
package/src/{v1 → v2}/actions.js
RENAMED
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
import { findServiceForDirectory } from "
|
|
2
|
-
import { getServiceLiveStatus, restartService, getServiceLogs } from "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const logsResult = getServiceLogs(detected.unitName, lines);
|
|
54
|
-
return {
|
|
55
|
-
...detected,
|
|
56
|
-
logsResult
|
|
57
|
-
};
|
|
58
|
-
}
|
|
1
|
+
import { findServiceForDirectory } from "ubuntu-service-detect";
|
|
2
|
+
import { getServiceLiveStatus, restartService, getServiceLogs } from "ubuntu-service-restart";
|
|
3
|
+
|
|
4
|
+
export function inspectCurrentService(targetDir = process.cwd(), options = {}) {
|
|
5
|
+
const detected = findServiceForDirectory(targetDir, options);
|
|
6
|
+
if (!detected.found) {
|
|
7
|
+
return detected;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const liveStatus = getServiceLiveStatus(detected.unitName);
|
|
11
|
+
return {
|
|
12
|
+
...detected,
|
|
13
|
+
liveStatus
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function restartCurrentService(targetDir = process.cwd(), options = {}) {
|
|
18
|
+
const detected = findServiceForDirectory(targetDir, options);
|
|
19
|
+
if (!detected.found) {
|
|
20
|
+
return {
|
|
21
|
+
success: false,
|
|
22
|
+
error: detected.message,
|
|
23
|
+
targetDir
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const restartResult = restartService(detected.unitName);
|
|
28
|
+
return {
|
|
29
|
+
...detected,
|
|
30
|
+
restartResult
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getCurrentServiceLogs(targetDir = process.cwd(), lines = 25, options = {}) {
|
|
35
|
+
const detected = findServiceForDirectory(targetDir, options);
|
|
36
|
+
if (!detected.found) {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
error: detected.message,
|
|
40
|
+
targetDir
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const logsResult = getServiceLogs(detected.unitName, lines);
|
|
45
|
+
return {
|
|
46
|
+
...detected,
|
|
47
|
+
logsResult
|
|
48
|
+
};
|
|
49
|
+
}
|