Skip to content

Commit aaf1e4f

Browse files
committed
generalized
modular eslint eslint generic modules documentation list doesn't need a name docs
1 parent 30d8e98 commit aaf1e4f

File tree

9 files changed

+1539
-400
lines changed

9 files changed

+1539
-400
lines changed

.eslintrc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"extends": "airbnb",
7+
"plugins": [
8+
"react",
9+
"jsx-a11y",
10+
"import"
11+
],
12+
"rules": {
13+
"comma-dangle": [
14+
"error",
15+
{
16+
"arrays": "only-multiline",
17+
"exports": "only-multiline",
18+
"functions": "ignore",
19+
"imports": "only-multiline",
20+
"objects": "only-multiline"
21+
}
22+
],
23+
"global-require": 0,
24+
"import/no-dynamic-require": 0,
25+
"import/prefer-default-export": 0,
26+
"max-len": [
27+
1,
28+
120,
29+
2,
30+
{
31+
"ignoreComments": true
32+
}
33+
],
34+
"no-confusing-arrow": 0,
35+
"no-console": 0,
36+
"no-underscore-dangle": 0,
37+
"no-unused-vars": 0,
38+
"react/jsx-filename-extension": 0,
39+
"react/jsx-indent": 0,
40+
"react/prop-types": 0,
41+
"semi": [
42+
"error",
43+
"never"
44+
]
45+
}
46+
}

README.md

Lines changed: 184 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ With jsctl you can generate and manage service files like the following:
66

77
```
88
[Unit]
9-
Description=Your description
10-
Wants=network-online.target
9+
Description=example-app
1110
1211
[Service]
1312
ExecStart=/path/to/node /path/to/project/index.js
1413
WorkingDirectory=/path/to/project/
1514
User=nobody
1615
Restart=always
17-
RestartSec=0
1816
StandardOutput=syslog+console
1917
StandardError=syslog+console
2018
Environment=NODE_ENV=production NODE_PORT=3000
@@ -23,6 +21,11 @@ Environment=NODE_ENV=production NODE_PORT=3000
2321
WantedBy=multi-user.target
2422
```
2523

24+
## Defaults
25+
26+
jsctl can use the name and main entries in your package.json and looks for your local Node.js installation.
27+
By default the resulting service will automatically restart your application on failure and has NODE_ENV=production set as an environment variable. Of course these defaults can be overridden.
28+
2629
## Installation
2730
```bash
2831
$ yarn global add jsctl
@@ -35,97 +38,225 @@ $ npm i -g jsctl
3538

3639
```bash
3740
$ cd path/to/example-app
38-
$ sudo jsctl generate -user $USER -env 'NODE_ENV=production NODE_PORT=3000'
39-
/etc/systemd/system/example-app.jsctl.service created
41+
$ sudo jsctl add -u $USER -e 'NODE_ENV=production NODE_PORT=3000'
42+
created example-app
4043
$ jsctl status
4144
● example-app.jsctl.service - example-app
4245
Loaded: loaded (/etc/systemd/system/example-app.jsctl.service; disabled; vendor preset: enabled)
4346
Active: inactive (dead)
4447
$ sudo jsctl start
48+
$ sudo jsctl enable
4549
Created symlink from /etc/systemd/system/multi-user.target.wants/example-app.jsctl.service to /etc/systemd/system/example-app.jsctl.service.
4650
$ cd /some/random/path
4751
$ jsctl list
4852
example-app
49-
$ sudo jsctl stop -n example-app
50-
Removed symlink /etc/systemd/system/multi-user.target.wants/example-app.jsctl.service.
51-
```
53+
$ jsctl cat example-app
54+
# /etc/systemd/system/example-app.jsctl.service
55+
[Unit]
56+
;After=
57+
;AllowIsolate=
58+
;Before=
59+
;BindsTo=
60+
;Conflicts=
61+
DefaultDependencies=true
62+
;Description=
63+
;Documentation=
64+
;IgnoreOnIsolate=
65+
;JobTimeoutAction=
66+
;JobTimeoutRebootArgument=
67+
JobTimeoutSec=infinity
68+
;JoinsNamespaceOf=
69+
;OnFailure=
70+
OnFailureJobMode=replace
71+
;PartOf=
72+
;PropagatesReloadFrom=
73+
;PropagatesReloadTo=
74+
;RebootArgument=
75+
;RefuseManualStart=
76+
;RefuseManualStop=
77+
;Requires=
78+
;RequiresMountsFor=
79+
;Requisite=
80+
StartLimitAction=none
81+
;StartLimitBurst=
82+
;StartLimitIntervalSec=
83+
;StopWhenUnneeded=
84+
;Wants=
85+
86+
[Service]
87+
;BusName=
88+
Environment=NODE_ENV=production NODE_PORT=3000
89+
;ExecReload=
90+
ExecStart=/usr/local/bin/node /home/user/path/to/example-app/index.js
91+
;ExecStartPre=
92+
;ExecStartPost=
93+
;ExecStop=
94+
;ExecStopPost=
95+
;FailureAction=
96+
;FileDescriptorStoreMax=
97+
GuessMainPID=yes
98+
;NonBlocking=
99+
;NotifyAccess=
100+
;PermissionsStartOnly=
101+
;PIDFile=
102+
;RemainAfterExit=
103+
Restart=always
104+
;RestartForceExitStatus=
105+
;RestartPreventExitStatus=
106+
RestartSec=100ms
107+
;RootDirectoryStartOnly=
108+
;RuntimeMaxSec=
109+
;Sockets=
110+
StandardOutput=syslog
111+
StandardError=syslog
112+
;SuccessExitStatus=
113+
TimeoutStartSec=90s
114+
TimeoutStopSec=90s
115+
Type=simple
116+
;USBFunctionDescriptors=
117+
;USBFunctionStrings=
118+
User=user
119+
;WatchdogSec=
120+
WorkingDirectory=/home/user/path/to/example-app
121+
122+
[Install]
123+
;Alias=
124+
;Also=
125+
;DefaultInstance=
126+
;RequiredBy=
127+
WantedBy=multi-user.target
52128

53-
```bash
54129
$ jsctl --help
55-
Usage: jsctl <command> [options]
130+
Usage: jsctl <command> [name] [options]
56131

57132
Commands:
133+
add Generate a service file
134+
list List services
135+
remove Remove a service file
58136
cat Display a service file
59137
daemon-reload Reload the daemon
60138
disable Disable a service
61139
enable Enable a service
62-
generate Generate a service file
63140
is-active See if active
64141
is-enabled See if enabled
65142
is-failed See if failed
66-
list List services
67143
list-dependencies List service dependencies
68144
reload Reload a service
69145
reload-or-restart Reload or restart service
70-
remove Remove a service file
71146
restart Restart a service
72147
show Show service properties
73148
start Start a service
74149
status See the status of a service
75150
stop Stop a service
76151

77152
Options:
78-
--custom Custom [Service] options, e.g. --custom
79-
'SuccessExitStatus=1\nType=simple' [default: ""]
80-
-d, --directory Path to project folder with package.json (default:
81-
process.cwd()) [default: "/current/working/directory"]
82-
-e, --env Evironment [default: "NODE_ENV=production"]
83-
-n, --name Name of a generated service
84-
--nodepath Path to node binary (default: process.argv[0])
85-
[default: "/usr/local/bin/node"]
86-
-s, --scriptpath Path to your JavaScript file (default: main entry in
87-
package.json)
88-
--stdout StandardOut
153+
--help, -h Show help [boolean]
154+
--version, -v Show version number [boolean]
155+
--after After
156+
--alias Alias
157+
--allowisolate AllowIsolate
158+
--also Also
159+
--before Before
160+
--bindsto BindsTo
161+
--busname BusName
162+
--conflicts Conflicts
163+
--defaultdependencies DefaultDependencies [default: true]
164+
--defaultinstance DefaultInstance
165+
--description Description
166+
--documentation Documentation
167+
--environment, -e Environment [default: "NODE_ENV=production"]
168+
--execreload ExecReload
169+
--execstart, -s [default: /path/to/node
170+
/path/to/package/json/main/script.js]
171+
--execstartpost ExecStartPost
172+
--execstartpre ExecStartPre
173+
--execstop ExecStop
174+
--execstoppost ExecStopPost
175+
--failureaction FailureAction
176+
--filedescriptorstoremax FileDescriptorStoreMax
177+
--guessmainpid GuessMainPID [default: "yes"]
178+
--ignoreonisolate IgnoreOnIsolate
179+
--jobtimeoutaction JobTimeoutAction
180+
--jobtimeoutrebootargument JobTimeoutRebootArgument
181+
--jobtimeoutsec JobTimeoutSec [default: "infinity"]
182+
--joinsnamespaceof JoinsNamespaceOf
183+
--nonblocking NonBlocking
184+
--notifyaccess NotifyAccess
185+
--onfailure OnFailure
186+
--onfailurejobmode OnFailureJobMode
187+
[choices: "fail", "replace", "replace-irreversibly", "isolate", "flush",
188+
"ignore-dependencies", "ignore-requirements"] [default: "replace"]
189+
--pidfile PIDFile
190+
--partof PartOf
191+
--permissionsstartonly PermissionsStartOnly
192+
--propagatesreloadfrom PropagatesReloadFrom
193+
--propagatesreloadto PropagatesReloadTo
194+
--rebootargument RebootArgument
195+
--refusemanualstart RefuseManualStart
196+
--refusemanualstop RefuseManualStop
197+
--remainafterexit RemainAfterExit
198+
--requiredby RequiredBy
199+
--requires Requires
200+
--requiresmountsfor RequiresMountsFor
201+
--requisite Requisite
202+
--restart Restart
203+
[choices: "always", "no", "on-success", "on-failure", "on-abnormal",
204+
"on-abort", "on-watchdog"] [default: "always"]
205+
--restartforceexitstatus RestartForceExitStatus
206+
--restartpreventexitstatus RestartPreventExitStatus
207+
--restartsec RestartSec [default: "100ms"]
208+
--rootdirectorystartonly RootDirectoryStartOnly
209+
--runtimemaxsec RuntimeMaxSec
210+
--sockets Sockets
211+
--standarderror StandardError
89212
[choices: "inherit", "null", "tty", "journal", "syslog", "kmsg",
90213
"journal+console", "syslog+console", "kmsg+console", "socket"] [default:
91214
"syslog"]
92-
--stderr StandardError
215+
--standardoutput StandardOutput
93216
[choices: "inherit", "null", "tty", "journal", "syslog", "kmsg",
94217
"journal+console", "syslog+console", "kmsg+console", "socket"] [default:
95218
"syslog"]
96-
-t, --timeout Timeout in seconds before process restarts [default: 0]
97-
-u, --user User who runs the process [default: "root"]
98-
--wants [choices: see: systemctl list-units --type target --all]
99-
[default: "network-online.target"]
100-
-h, --help Show help [boolean]
101-
--restart [choices: "no", "always", "on-success", "on-failure", "on-abnormal",
102-
"on-abort", "on-watchdog"] [default: "always"]
103-
--wantedby [choices: "multi-user.target", "graphical.target", "rescue.target",
219+
--startlimitaction StartLimitAction
220+
[choices: "none", "poweroff", "poweroff-force", "poweroff-immediate",
221+
"reboot", "reboot-force", "reboot-immediate"] [default: "none"]
222+
--startlimitburst StartLimitBurst
223+
--startlimitintervalsec StartLimitIntervalSec
224+
--stopwhenunneeded StopWhenUnneeded
225+
--successexitstatus SuccessExitStatus
226+
--timeoutstartsec TimeoutStartSec [default: "90s"]
227+
--timeoutstopsec TimeoutStopSec [default: "90s"]
228+
--type Type
229+
[choices: "dbus", "forking", "idle", "notify", "oneshot", "simple"] [default:
230+
"simple"]
231+
--usbfunctiondescriptors USBFunctionDescriptors
232+
--usbfunctionstrings USBFunctionStrings
233+
--user, -u User [default: "root"]
234+
--wantedby WantedBy
235+
[choices: "multi-user.target", "graphical.target", "rescue.target",
104236
"reboot.target", "poweroff.target"] [default: "multi-user.target"]
237+
--wants Wants
238+
--watchdogsec WatchdogSec
239+
--workingdirectory /current/working/directory
240+
--assertions comma seperated list of assertions
241+
--conditions comma seperated list of conditions
105242

106243
Examples:
107-
GENERATE
244+
ADD
108245

109246
From your projects root directory:
110-
sudo jsctl generate
111-
112-
By telling jsctl where to find your pacakge.json:
113-
sudo jsctl generate -d /path/to/project
114-
115-
Br by providing name and scriptpath arguments:
116-
sudo jsctl generate -n example-app -s /path/to/script.js
247+
sudo jsctl add
248+
sudo jsctl add -u $USER -e 'NODE_ENV=development NODE_PORT=3000'
117249

118-
A more customized example:
119-
sudo jsctl generate -u $USER -e 'NODE_ENV=development NODE_PORT=3000'
120-
--stdout journal+console
250+
By providing a name and --execstart:
251+
sudo jsctl add example-app -s '/usr/local/bin/node /path/to/script.js'
121252

122253
GENERAL
123254

124255
If you want to manage a service and you are not in its projects root folder,
125-
you have to provide the name:
256+
you have to provide its name:
126257

127-
sudo jsctl stop -n example-app
128-
jsctl cat -n example-app
258+
sudo jsctl stop example-app
259+
jsctl cat example-app
129260
```
130261
131262
Local installation example:
@@ -139,13 +270,13 @@ $ npm i --save-dev jsctl
139270
```js
140271
// package.json
141272
{
142-
"name": "example-app", // required
143-
"main": "path/to/script.js", // required
273+
"name": "example-app",
274+
"main": "path/to/script.js",
144275
"scripts": {
145-
"generate": "sudo ./node_modules/.bin/jsctl generate -u $USER",
146-
"start": "sudo ./node_modules/.bin/jsctl start",
147-
"status": "jsctl status",
148-
"stop": "sudo ./node_modules/.bin/jsctl stop"
276+
"service:add": "sudo ./node_modules/.bin/jsctl add -u $USER",
277+
"service:start": "sudo ./node_modules/.bin/jsctl start",
278+
"service:status": "jsctl status",
279+
"service:stop": "sudo ./node_modules/.bin/jsctl stop"
149280
}
150281
}
151282
```

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,12 @@
3939
"cron",
4040
"watcher",
4141
"watchdog"
42-
]
42+
],
43+
"devDependencies": {
44+
"eslint": "^3.17.1",
45+
"eslint-config-airbnb": "^14.1.0",
46+
"eslint-plugin-import": "^2.2.0",
47+
"eslint-plugin-jsx-a11y": "^4.0.0",
48+
"eslint-plugin-react": "^6.10.0"
49+
}
4350
}

0 commit comments

Comments
 (0)