32 Commits

Author SHA1 Message Date
769d7d6419 1.0.20 2019-09-19 19:37:35 +02:00
49dd65af05 fix(core): update 2019-09-19 19:37:34 +02:00
d550318331 1.0.19 2019-09-19 15:58:44 +02:00
9fc71fcfee fix(core): update 2019-09-19 15:58:43 +02:00
119f20915e 1.0.18 2019-09-06 17:33:02 +02:00
ce1fa6640b fix(core): update 2019-09-06 17:33:01 +02:00
8957e03445 1.0.17 2019-09-05 16:19:18 +02:00
3df86bee10 fix(core): update 2019-09-05 16:19:18 +02:00
65326710ab 1.0.16 2019-09-05 16:14:05 +02:00
2e174c9f55 fix(core): update 2019-09-05 16:14:05 +02:00
9e42910456 1.0.15 2019-09-05 16:04:38 +02:00
ff85cee528 fix(core): update 2019-09-05 16:04:38 +02:00
2a9fff0185 1.0.14 2019-09-05 15:48:00 +02:00
67689d79bd fix(core): update 2019-09-05 15:48:00 +02:00
f8c851de97 1.0.13 2019-09-05 13:50:11 +02:00
09e9d8c190 fix(core): update 2019-09-05 13:50:11 +02:00
80f5df3317 1.0.12 2019-09-05 11:15:17 +02:00
6cf3ff6e83 fix(core): update 2019-09-05 11:15:17 +02:00
ceb30c7ac2 1.0.11 2019-09-04 16:51:58 +02:00
0df90eec5d fix(core): update 2019-09-04 16:51:58 +02:00
261031a49c 1.0.10 2019-09-03 22:09:31 +02:00
615cc6aa7c fix(core): update 2019-09-03 22:09:30 +02:00
c9aa7fed48 1.0.9 2019-09-03 19:58:08 +02:00
44d30fc4d6 fix(core): update 2019-09-03 19:58:08 +02:00
dd5e1a978d 1.0.8 2019-09-03 16:50:25 +02:00
692602b463 fix(core): update 2019-09-03 16:50:24 +02:00
382b694027 1.0.7 2019-09-03 15:24:50 +02:00
de831b086f fix(core): update 2019-09-03 15:24:49 +02:00
01c7d2e482 1.0.6 2019-09-03 15:21:30 +02:00
49ebf991a2 fix(core): update 2019-09-03 15:21:30 +02:00
513337355f 1.0.5 2019-09-03 11:29:14 +02:00
5e5a679f99 fix(core): update 2019-09-03 11:29:14 +02:00
13 changed files with 479 additions and 653 deletions

270
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartdaemon",
"version": "1.0.4",
"version": "1.0.20",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -93,24 +93,17 @@
}
},
"@pushrocks/lik": {
"version": "3.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.5.tgz",
"integrity": "sha512-pc5Nq0WUysS34qPpyiZXiX254kL3vyRVbt3D36Q5QU+eHhxAThHofSzgOdyVHUZU2WFoaMlKowIVsyUFzIkfdw==",
"version": "3.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.11.tgz",
"integrity": "sha512-SDKRPj9+xBTqozlDPcA7O6BcccM1Tw/sXPVP+OnhNxCubDZ/L2kGNpPpqm43NJUoNxSSo5wdBw4N7MAFYCGdVg==",
"requires": {
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smarttime": "^3.0.5",
"@pushrocks/smarttime": "^3.0.12",
"@types/minimatch": "^3.0.3",
"minimatch": "^3.0.4",
"symbol-tree": "^3.2.2"
},
"dependencies": {
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
"symbol-tree": "^3.2.4"
}
},
"@pushrocks/smartcli": {
@ -144,6 +137,23 @@
"@pushrocks/smartpromise": "^3.0.2"
}
},
"@pushrocks/smartenv": {
"version": "4.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.7.tgz",
"integrity": "sha512-ThSJMEcUAF1VIa4vAvn1zGnziEuDY4h8T+EQ5JCiKy2qnUM/F6zqzFogyo495X6rg71gC/7RmktQVQaN06gjWA==",
"requires": {
"@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^3.0.2",
"@types/node": "^12.7.2"
},
"dependencies": {
"@types/node": {
"version": "12.7.3",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.3.tgz",
"integrity": "sha512-3SiLAIBkDWDg6vFo0+5YJyHPWU9uwu40Qe+v+0MH8wRKYBimHvvAOyk3EzMrD/TrIlLYfXrqDqrg913PynrMJQ=="
}
}
},
"@pushrocks/smartevent": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",
@ -170,10 +180,9 @@
}
},
"@pushrocks/smartfile": {
"version": "7.0.2",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.2.tgz",
"integrity": "sha512-38l9DRalp1McEBFG+qKzBqefVQZZLPNk+uo7Ff1guy8BDxA+tATlZ6O6FuXW7M3wjFDBi245VJs+KWVKcCxBRA==",
"dev": true,
"version": "7.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.4.tgz",
"integrity": "sha512-ym8eigWJAQhwgmuVLew3GLrk4WhV03ajapwuMWytxKSzfIW9ZqceJBX2QzOkmhFGA2bp+gc4Q2wOBy3Ffnlj+A==",
"requires": {
"@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^3.0.2",
@ -190,7 +199,6 @@
"version": "5.1.0",
"resolved": "https://verdaccio.lossless.one/@types%2ffs-extra/-/fs-extra-5.1.0.tgz",
"integrity": "sha512-AInn5+UBFIK9FK5xc9yP5e3TQSPNNgjHByqYcj9g5elVBnDQcQL7PlO1CIRy2gWlbwK7UPYqi7vRvFA44dCmYQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
@ -199,7 +207,6 @@
"version": "7.0.1",
"resolved": "https://verdaccio.lossless.one/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
@ -208,6 +215,14 @@
}
}
},
"@pushrocks/smartfm": {
"version": "2.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfm/-/smartfm-2.0.4.tgz",
"integrity": "sha512-QYxmIGhRfnE57rTCjsDBilPTrO/3VmajDxQt5z14pxAm9CeZypyGc4N6+Ts3KT1VGbs68NzCsGOM5ZYJW0Wmfg==",
"requires": {
"gray-matter": "^4.0.2"
}
},
"@pushrocks/smartlog": {
"version": "2.0.19",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog/-/smartlog-2.0.19.tgz",
@ -251,7 +266,6 @@
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartparam/-/smartparam-1.0.4.tgz",
"integrity": "sha512-UAqhnTQGBaJRptTK3qTd47Yt2ZTrAWByteow4auSNZD+k0xrpY9mTPPgKh0IwsURe0cZhj7zYNpGiekhKkL4rA==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"is-promise": "^2.1.0",
@ -261,16 +275,14 @@
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==",
"dev": true
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
}
},
"@pushrocks/smartpath": {
"version": "4.0.1",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-4.0.1.tgz",
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==",
"dev": true
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA=="
},
"@pushrocks/smartpromise": {
"version": "3.0.2",
@ -278,10 +290,9 @@
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
},
"@pushrocks/smartrequest": {
"version": "1.1.16",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.16.tgz",
"integrity": "sha512-3LbtqoqnjfzWSQ10NryhJmgwPpvMlVoYyTzE676+yC4hM2rnGSzxozLZxMr6enV4VeZcloQ0CqHBivKoT/kdvA==",
"dev": true,
"version": "1.1.23",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.23.tgz",
"integrity": "sha512-Hws3YfzIE0b/E3aTkSugLskKWBq7e8HDXEN+RlRyTFONxW/XONKJFTw4mp3jk+puWpYGDoOTcP+Ua4jd19z9pA==",
"requires": {
"@pushrocks/smartpromise": "^3.0.2",
"@types/form-data": "^2.2.1",
@ -318,6 +329,32 @@
"which": "^1.3.1"
}
},
"@pushrocks/smartsystem": {
"version": "2.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsystem/-/smartsystem-2.0.8.tgz",
"integrity": "sha512-lBruo1Ikai35oiDMy3Lx1NhddTMynCCd8MTx4dBU22a0HnNYZRKxTITuPAfIDD3VB94ZpEGbAvzblnZpuFFkMQ==",
"requires": {
"@pushrocks/lik": "^3.0.10",
"@pushrocks/smartenv": "^4.0.7",
"@pushrocks/smartpromise": "^3.0.2"
},
"dependencies": {
"@pushrocks/lik": {
"version": "3.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.11.tgz",
"integrity": "sha512-SDKRPj9+xBTqozlDPcA7O6BcccM1Tw/sXPVP+OnhNxCubDZ/L2kGNpPpqm43NJUoNxSSo5wdBw4N7MAFYCGdVg==",
"requires": {
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smarttime": "^3.0.12",
"@types/minimatch": "^3.0.3",
"minimatch": "^3.0.4",
"symbol-tree": "^3.2.4"
}
}
}
},
"@pushrocks/smarttime": {
"version": "3.0.12",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.12.tgz",
@ -385,20 +422,11 @@
}
},
"@types/form-data": {
"version": "2.2.1",
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.2.1.tgz",
"integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==",
"dev": true,
"version": "2.5.0",
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
"requires": {
"@types/node": "*"
}
},
"@types/fs-extra": {
"version": "8.0.0",
"resolved": "https://verdaccio.lossless.one/@types%2ffs-extra/-/fs-extra-8.0.0.tgz",
"integrity": "sha512-bCtL5v9zdbQW86yexOlXWTEGvLNqWxMFyi7gQA7Gcthbezr2cPSOb8SkESVKA937QD5cIwOFLDFt0MQoXOEr9Q==",
"requires": {
"@types/node": "*"
"form-data": "*"
}
},
"@types/luxon": {
@ -420,7 +448,6 @@
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@types%2fvinyl/-/vinyl-2.0.3.tgz",
"integrity": "sha512-hrT6xg16CWSmndZqOTJ6BGIn2abKyTw0B58bI+7ioUoj3Sma6u8ftZ1DTI2yCaJamOVGLOnQWiPH3a74+EaqTA==",
"dev": true,
"requires": {
"@types/node": "*"
}
@ -465,7 +492,6 @@
"version": "1.0.10",
"resolved": "https://verdaccio.lossless.one/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
@ -479,8 +505,7 @@
"asynckit": {
"version": "0.4.0",
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"balanced-match": {
"version": "1.0.0",
@ -586,26 +611,22 @@
"clone": {
"version": "2.1.2",
"resolved": "https://verdaccio.lossless.one/clone/-/clone-2.1.2.tgz",
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
"dev": true
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18="
},
"clone-buffer": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/clone-buffer/-/clone-buffer-1.0.0.tgz",
"integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=",
"dev": true
"integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg="
},
"clone-stats": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/clone-stats/-/clone-stats-1.0.0.tgz",
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
"dev": true
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA="
},
"cloneable-readable": {
"version": "1.1.3",
"resolved": "https://verdaccio.lossless.one/cloneable-readable/-/cloneable-readable-1.1.3.tgz",
"integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"process-nextick-args": "^2.0.0",
@ -635,7 +656,6 @@
"version": "1.0.8",
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
@ -654,8 +674,7 @@
"core-util-is": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cron": {
"version": "1.7.1",
@ -711,8 +730,7 @@
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"diff": {
"version": "4.0.1",
@ -737,8 +755,7 @@
"esprima": {
"version": "4.0.1",
"resolved": "https://verdaccio.lossless.one/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esutils": {
"version": "2.0.2",
@ -761,6 +778,14 @@
"strip-eof": "^1.0.0"
}
},
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://verdaccio.lossless.one/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"requires": {
"is-extendable": "^0.1.0"
}
},
"figures": {
"version": "3.0.0",
"resolved": "https://verdaccio.lossless.one/figures/-/figures-3.0.0.tgz",
@ -783,44 +808,24 @@
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
"integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=",
"dev": true,
"requires": {
"readable-stream": "^2.0.2"
}
},
"form-data": {
"version": "2.4.0",
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.4.0.tgz",
"integrity": "sha512-4FinE8RfqYnNim20xDwZZE0V2kOs/AuElIjFUbPuegQSaoZM+vUT5FnwSl10KPugH4voTg1bEQlcbCG9ka75TA==",
"dev": true,
"version": "2.5.1",
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.1.tgz",
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://verdaccio.lossless.one/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
},
"dependencies": {
"graceful-fs": {
"version": "4.2.2",
"resolved": "https://verdaccio.lossless.one/graceful-fs/-/graceful-fs-4.2.2.tgz",
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q=="
}
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"get-caller-file": {
"version": "1.0.3",
@ -847,7 +852,6 @@
"version": "7.1.4",
"resolved": "https://verdaccio.lossless.one/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -858,9 +862,20 @@
}
},
"graceful-fs": {
"version": "4.1.15",
"resolved": "https://verdaccio.lossless.one/graceful-fs/-/graceful-fs-4.1.15.tgz",
"integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA=="
"version": "4.2.2",
"resolved": "https://verdaccio.lossless.one/graceful-fs/-/graceful-fs-4.2.2.tgz",
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q=="
},
"gray-matter": {
"version": "4.0.2",
"resolved": "https://verdaccio.lossless.one/gray-matter/-/gray-matter-4.0.2.tgz",
"integrity": "sha512-7hB/+LxrOjq/dd8APlK0r24uL/67w7SkYnfwhNFwg/VDIGWGmduTDYf3WNstLW2fbbmRwrDGCVSJ2isuf2+4Hw==",
"requires": {
"js-yaml": "^3.11.0",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
}
},
"has-flag": {
"version": "3.0.0",
@ -871,7 +886,6 @@
"version": "1.0.6",
"resolved": "https://verdaccio.lossless.one/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -880,8 +894,7 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://verdaccio.lossless.one/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"invert-kv": {
"version": "2.0.0",
@ -889,6 +902,11 @@
"integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==",
"dev": true
},
"is-extendable": {
"version": "0.1.1",
"resolved": "https://verdaccio.lossless.one/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik="
},
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
@ -898,8 +916,7 @@
"is-promise": {
"version": "2.1.0",
"resolved": "https://verdaccio.lossless.one/is-promise/-/is-promise-2.1.0.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
},
"is-stream": {
"version": "1.1.0",
@ -910,14 +927,12 @@
"is-utf8": {
"version": "0.2.1",
"resolved": "https://verdaccio.lossless.one/is-utf8/-/is-utf8-0.2.1.tgz",
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
"dev": true
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isexe": {
"version": "2.0.0",
@ -934,7 +949,6 @@
"version": "3.13.1",
"resolved": "https://verdaccio.lossless.one/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
@ -948,6 +962,11 @@
"graceful-fs": "^4.1.6"
}
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://verdaccio.lossless.one/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
},
"lcid": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/lcid/-/lcid-2.0.0.tgz",
@ -1009,14 +1028,12 @@
"mime-db": {
"version": "1.40.0",
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==",
"dev": true
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"dev": true,
"requires": {
"mime-db": "1.40.0"
}
@ -1090,7 +1107,6 @@
"version": "1.4.0",
"resolved": "https://verdaccio.lossless.one/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
@ -1200,8 +1216,7 @@
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-key": {
"version": "2.0.1",
@ -1224,14 +1239,12 @@
"pify": {
"version": "2.3.0",
"resolved": "https://verdaccio.lossless.one/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://verdaccio.lossless.one/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"pump": {
"version": "3.0.0",
@ -1247,7 +1260,6 @@
"version": "2.3.6",
"resolved": "https://verdaccio.lossless.one/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@ -1261,14 +1273,12 @@
"remove-trailing-separator": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
"dev": true
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8="
},
"replace-ext": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/replace-ext/-/replace-ext-1.0.0.tgz",
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=",
"dev": true
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
},
"require-directory": {
"version": "2.1.1",
@ -1311,8 +1321,16 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://verdaccio.lossless.one/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"section-matter": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/section-matter/-/section-matter-1.0.0.tgz",
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
"requires": {
"extend-shallow": "^2.0.1",
"kind-of": "^6.0.0"
}
},
"semver": {
"version": "5.7.0",
@ -1379,8 +1397,7 @@
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"string-width": {
"version": "2.1.1",
@ -1396,7 +1413,6 @@
"version": "1.1.1",
"resolved": "https://verdaccio.lossless.one/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
"safe-buffer": "~5.1.0"
}
@ -1414,7 +1430,6 @@
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/strip-bom/-/strip-bom-2.0.0.tgz",
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
"dev": true,
"requires": {
"is-utf8": "^0.2.0"
}
@ -1423,7 +1438,6 @@
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz",
"integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=",
"dev": true,
"requires": {
"is-utf8": "^0.2.1"
}
@ -1432,12 +1446,16 @@
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz",
"integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=",
"dev": true,
"requires": {
"first-chunk-stream": "^2.0.0",
"strip-bom": "^2.0.0"
}
},
"strip-bom-string": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI="
},
"strip-eof": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/strip-eof/-/strip-eof-1.0.0.tgz",
@ -1539,14 +1557,12 @@
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://verdaccio.lossless.one/vinyl/-/vinyl-2.2.0.tgz",
"integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
"dev": true,
"requires": {
"clone": "^2.1.1",
"clone-buffer": "^1.0.0",
@ -1560,7 +1576,6 @@
"version": "3.0.0",
"resolved": "https://verdaccio.lossless.one/vinyl-file/-/vinyl-file-3.0.0.tgz",
"integrity": "sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"pify": "^2.3.0",
@ -1641,8 +1656,7 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"y18n": {
"version": "4.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartdaemon",
"version": "1.0.4",
"version": "1.0.20",
"private": false,
"description": "start scripts as long running daemons and manage them",
"main": "dist/index.js",
@ -21,11 +21,13 @@
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@pushrocks/lik": "^3.0.11",
"@pushrocks/smartfile": "^7.0.4",
"@pushrocks/smartfm": "^2.0.4",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^8.0.2",
"@pushrocks/smartshell": "^2.0.25",
"@types/fs-extra": "^8.0.0",
"fs-extra": "^8.1.0"
"@pushrocks/smartsystem": "^2.0.8"
},
"files": [
"ts/*",

View File

@ -1,8 +1,21 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartdaemon from '../ts/index';
tap.test('first test', async () => {
console.log(smartdaemon.standardExport);
let testSmartdaemon: smartdaemon.SmartDaemon;
tap.test('should create an instance of smartdaemon', async () => {
testSmartdaemon = new smartdaemon.SmartDaemon();
expect(testSmartdaemon).to.be.instanceOf(smartdaemon.SmartDaemon);
});
tap.test('should create a service', async () => {
testSmartdaemon.addService({
name: 'npmversion',
version: 'x.x.x',
command: 'npm -v',
description: 'displays the npm version',
workingDir: __dirname
});
});
tap.start();

View File

@ -1,3 +1 @@
import * as plugins from './smartdaemon.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smartdaemon.classes.smartdaemon';

View File

@ -0,0 +1,84 @@
import * as plugins from './smartdaemon.plugins';
import * as paths from './smartdaemon.paths';
import { SmartDaemon } from './smartdaemon.classes.smartdaemon';
export interface ISmartDaemonServiceConstructorOptions {
name: string;
description: string;
command: string;
workingDir: string;
version: string;
}
/**
* represents a service that is being spawned by SmartDaemon
*/
export class SmartDaemonService implements ISmartDaemonServiceConstructorOptions {
public static async createFromOptions(smartdaemonRef: SmartDaemon, optionsArg: ISmartDaemonServiceConstructorOptions) {
const service = new SmartDaemonService(smartdaemonRef);
for (const key of Object.keys(optionsArg)) {
service[key] = optionsArg[key];
}
return service;
}
public options: ISmartDaemonServiceConstructorOptions;
public alreadyExists = false;
public name: string;
public version: string;
public command: string;
public workingDir: string;
public description: string;
public smartdaemonRef: SmartDaemon;
constructor(smartdaemonRegfArg: SmartDaemon) {
this.smartdaemonRef = smartdaemonRegfArg;
}
/**
* enables the service
*/
public async enable() {
await this.smartdaemonRef.systemdManager.enableService(this);
}
/**
* disables the service
*/
public async disable() {
await this.smartdaemonRef.systemdManager.disableService(this);
}
/**
* starts a service
*/
public async start() {
await this.smartdaemonRef.systemdManager.startService(this);
}
/**
* stops a service
*/
public async stop() {
await this.smartdaemonRef.systemdManager.stopService(this);
}
// Save and Delete
public async save() {
await this.smartdaemonRef.systemdManager.saveService(this);
}
/**
* deletes the service
*/
public async delete() {
await this.smartdaemonRef.systemdManager.deleteService(this);
}
public async reload() {
await this.smartdaemonRef.systemdManager.reload();
}
}

View File

@ -0,0 +1,38 @@
import * as plugins from './smartdaemon.plugins';
import { SmartDaemonTemplateManager } from './smartdaemon.classes.templatemanager';
import { SmartDaemonService, ISmartDaemonServiceConstructorOptions } from './smartdaemon.classes.service';
import { SmartDaemonSystemdManager } from './smartdaemon.classes.systemdmanager';
export class SmartDaemon {
public templateManager: SmartDaemonTemplateManager;
public systemdManager: SmartDaemonSystemdManager;
constructor() {
this.templateManager = new SmartDaemonTemplateManager(this);
this.systemdManager = new SmartDaemonSystemdManager(this);
}
/**
* adds a service
* @param nameArg
* @param commandArg
* @param workingDirectoryArg
*/
public async addService(optionsArg: ISmartDaemonServiceConstructorOptions): Promise<SmartDaemonService> {
let serviceToAdd: SmartDaemonService;
const existingServices = await this.systemdManager.getServices();
const existingService = existingServices.find(serviceArg => {
return serviceArg.name === optionsArg.name;
});
if (!existingService) {
serviceToAdd = await SmartDaemonService.createFromOptions(this, optionsArg);
} else {
serviceToAdd = existingService;
Object.assign(serviceToAdd, optionsArg);
}
await serviceToAdd.save();
return serviceToAdd;
}
}

View File

@ -0,0 +1,138 @@
import * as plugins from './smartdaemon.plugins';
import * as paths from './smartdaemon.paths';
import { SmartDaemon } from './smartdaemon.classes.smartdaemon';
import { ISmartDaemonServiceConstructorOptions, SmartDaemonService } from './smartdaemon.classes.service';
export class SmartDaemonSystemdManager {
// STATIC
private static smartDaemonNamespace = 'smartdaemon';
public static createServiceNameFromServiceName (serviceNameArg: string) {
return `${SmartDaemonSystemdManager.smartDaemonNamespace}_${serviceNameArg}`;
}
public static createFileNameFromServiceName (serviceNameArg: string) {
return `${SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceNameArg)}.service`;
};
public static createFilePathFromServiceName (serviceNameArg: string) {
return plugins.path.join(
paths.systemdDir,
SmartDaemonSystemdManager.createFileNameFromServiceName(serviceNameArg)
);
}
// INSTANCE
public smartdaemonRef: SmartDaemon;
public smartshellInstance: plugins.smartshell.Smartshell;
public smartsystem: plugins.smartsystem.Smartsystem;
public shouldExecute: boolean = false;
constructor(smartdaemonRefArg: SmartDaemon) {
this.smartdaemonRef = smartdaemonRefArg;
this.smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
this.smartsystem = new plugins.smartsystem.Smartsystem();
}
public async checkElegibility() {
if (await this.smartsystem.env.isLinuxAsync()) {
this.shouldExecute = true;
} else {
console.log('Smartdaemon can only be used on Linux systems! Refusing to set up a service.');
this.shouldExecute = false;
}
return this.shouldExecute;
}
public async execute(commandArg: string) {
if (await this.checkElegibility()) {
await this.smartshellInstance.exec(commandArg);
}
}
/**
* gets all services that are already present
*/
public async getServices() {
const existingServices: SmartDaemonService[] = [];
if (await this.checkElegibility()) {
const smartfmInstance = new plugins.smartfm.Smartfm({
fmType: 'yaml'
});
const availableServices = await plugins.smartfile.fs.fileTreeToObject(
paths.systemdDir,
'smartdaemon_*.service'
);
for (const serviceFile of availableServices) {
const data = smartfmInstance.parseFromComments('# ', serviceFile.contentBuffer.toString())
.data as ISmartDaemonServiceConstructorOptions;
const service = await SmartDaemonService.createFromOptions(this.smartdaemonRef, data);
service.alreadyExists = true;
existingServices.push(service);
}
}
return existingServices;
}
public async startService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await this.execute(
`systemctl start ${SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceArg.name)}`
);
}
}
public async stopService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await this.execute(
`systemctl stop ${SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceArg.name)}`
);
}
}
public async saveService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await plugins.smartfile.memory.toFs(
this.smartdaemonRef.templateManager.generateUnitFileForService(serviceArg),
SmartDaemonSystemdManager.createFilePathFromServiceName(serviceArg.name)
);
}
}
public async deleteService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await plugins.smartfile.fs.remove(
SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceArg.name)
);
}
}
public async enableService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await this.saveService(serviceArg);
if (serviceArg.alreadyExists) {
await this.execute(`systemctl daemon-reload`);
}
await this.execute(
`systemctl enable ${SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceArg.name)}`
);
}
}
public async disableService(serviceArg: SmartDaemonService) {
if (await this.checkElegibility()) {
await this.execute(
`systemctl disable ${SmartDaemonSystemdManager.createServiceNameFromServiceName(serviceArg.name)}`
);
}
}
public async reload() {
if (await this.checkElegibility()) {
await this.execute(
`systemctl daemon-reload`
);
}
}
}

View File

@ -0,0 +1,41 @@
import * as plugins from './smartdaemon.plugins';
import { SmartDaemon } from './smartdaemon.classes.smartdaemon';
import { SmartDaemonService } from './smartdaemon.classes.service';
export class SmartDaemonTemplateManager {
public smartdaemonRef: SmartDaemon;
constructor(smartdaemonRefArg: SmartDaemon) {
this.smartdaemonRef = smartdaemonRefArg;
}
public generateUnitFileForService = (serviceArg: SmartDaemonService) => {
return `# ---
# name: ${serviceArg.name}
# version: ${serviceArg.version}
# description: ${serviceArg.description}
# command: ${serviceArg.command}
# workingDir: ${serviceArg.workingDir}
# ---
[Unit]
Description=${serviceArg.description}
Requires=network.target
After=network.target
[Service]
Type=simple
Environment=NODE_OPTIONS="--max_old_space_size=100"
ExecStart=/bin/bash -c "cd ${serviceArg.workingDir} && ${serviceArg.command}"
WorkingDirectory=${serviceArg.workingDir}
Restart=on-failure
LimitNOFILE=infinity
LimitCORE=infinity
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always
[Install]
WantedBy=multi-user.target
`;
}
}

4
ts/smartdaemon.paths.ts Normal file
View File

@ -0,0 +1,4 @@
import * as plugins from './smartdaemon.plugins';
export const packageDir = plugins.path.join(__dirname, '../');
export const systemdDir = plugins.path.join('/lib/systemd/system/');

View File

@ -7,20 +7,22 @@ export {
};
// @pushrocks scope
import * as smartshell from '@pushrocks/smartshell';
import * as lik from '@pushrocks/lik';
import * as smartfile from '@pushrocks/smartfile';
import * as smartfm from '@pushrocks/smartfm';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartshell from '@pushrocks/smartshell';
import * as smartsystem from '@pushrocks/smartsystem';
export {
smartshell,
lik,
smartfile,
smartfm,
smartlog,
smartlogDestinationLocal
smartlogDestinationLocal,
smartshell,
smartsystem
};
// third party
import * as fs from 'fs-extra';
export {
fs
};

View File

@ -1,174 +0,0 @@
export const settingsReference = {
name: {
cli: {
short: 'n',
long: 'service',
value: '[name]',
description: 'Service name'
},
mandatory: true
},
description: {
cli: {
short: 'd',
long: 'description',
value: '[description]',
description: 'Service description'
},
default: '{name} service'
},
author: {
cli: {
short: 'k',
long: 'author',
value: '[author]',
description: 'Service author'
}
},
user: {
cli: {
short: 'u',
long: 'user',
value: '[user]',
description: 'User to run service as'
}
},
group: {
cli: {
short: 'g',
long: 'group',
value: '[group]',
description: 'Group to run service as'
}
},
app: {
cli: {
short: 'A',
long: 'app',
value: '[app]',
description: 'Application main file'
},
default: 'main.js'
},
cwd: {
cli: {
short: 'c',
long: 'cwd',
value: '[path]',
description: 'Application cwd'
},
mandatory: true,
fs: true
},
'app.args': {
cli: {
short: 'p',
long: 'app.args',
value: '[args]',
description: 'Application arguments'
}
},
env: {
cli: {
short: 'e',
long: 'env',
value: '[NAME=VALUE]',
description: 'Environment variables to set in systemd job',
function: (v, vars) => {
const _v = v.split('=')
vars[_v[0]] = _v[1]; return vars
},
store: []
}
},
pid: {
cli: {
short: 'P',
long: 'pid',
value: '[file]',
description: 'Service pid file'
},
default: '/var/run/{name}.pid'
},
log: {
cli: {
short: 'L',
long: 'log',
value: '[log]',
description: 'Service log file'
},
default: '/var/log/{name}/log'
},
error: {
cli: {
short: 'E',
long: 'error',
value: '[error]',
description: 'Service error file'
},
default: '/var/log/{name}/error'
},
engine: {
cli: {
short: 'X',
long: 'engine',
value: '[node|forever|pm2]',
description: 'Service engine (node|forever|pm2)'
},
default: 'node',
mandatory: true
},
'engine.bin': {
cli: {
short: 'b',
long: 'engine.bin',
value: '[bin]',
description: 'Service engine bin'
},
default: '/usr/bin/{engine}',
fs: true
},
'engine.args': {
cli: {
short: 't',
long: 'engine.args',
value: '[eargs]',
description: 'Service engine args'
}
},
logrotate: {
cli: {
short: 'l',
long: 'logrotate',
description: 'Add logrotate config'
}
// default false
},
'logrotate.rotate': {
cli: {
short: 'R',
long: 'logrotate.rotate',
value: '[rotate]',
description: 'Logrotate rotations'
},
default: 10
},
'logrotate.frequency': {
cli: {
short: 'F',
long: 'logrotate.frequency',
value: '[frequency]',
description: 'Logrotate frequency'
},
default: 'daily'
},
noroot: {
cli: {
short: 'w',
long: 'noroot',
description: 'Skip check for root permission'
}
}
};

View File

@ -1,259 +0,0 @@
import * as plugins from './smartdaemon.plugins';
import { logger } from './smartdamon.logging';
import { settingsReference } from './smartdaemon.settings';
import { templateReference } from './smartdaemon.templates';
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
/**
* print success message
* @method setup.success
* @param {string} message
*/
export const setupSuccess = (message: string) => {
logger.log('success', `service-systemd: ${message}`);
};
/**
* print error message
* @method setup.fail
* @param {string} message
*/
export const setupFail = (message) => {
logger.log('error', `service-systemd ${message}`);
};
/**
* install the service
* can also be used to update the service
* @method setup.add
* @param {object} settings
* @return {string}
*/
export const setupAdd = async (settings) => {
setupCheckSettings(settings);
const contents = setupParse(settings);
await setupCheckPaths(settings);
await setupAddLog(settings);
await setupAddScripts(settings, contents);
await setupAddLogrotate(settings, contents);
return `service ${settings.name} installed`;
};
/**
* remove the service
* @method setup.remove
* @param {string} service service name
* @return {string}
*/
export const setupRemove = async (service) => {
if (!service) {
throw new Error('Missing argument: service name');
}
const cmd = `systemctl disable ${service}.service`;
logger.log('info', `service-systemd > ${cmd}`);
await smartshellInstance.exec(cmd);
let file = plugins.path.join('/etc/systemd/system', `${service}.service`);
logger.log('info', `service-systemd remove ${file}`);
await plugins.fs.unlink(file);
file = plugins.path.join('/usr/local/bin', `systemd-${service}-start`);
logger.log('info', `service-systemd remove ${file}`);
await plugins.fs.unlink(file);
file = plugins.path.join('/etc/logrotate.d', service);
logger.log('info', `service-systemd remove ${file}`);
await plugins.fs.unlink(file);
return `service ${service} uninstalled`;
};
/**
* check mandatories params and paths
* @method setup.checkSettings
* @param {object} settings
*/
export const setupCheckSettings = (settings) => {
if (!settings.name) {
settings.name = settings.service;
}
delete settings.service;
const paths = [];
for (const optionArg of Object.keys(settingsReference)) {
const option = settingsReference[optionArg];
if (option.mandatory && !settings[optionArg]) {
throw new Error(`Missing ${optionArg} in settings file or arguments`);
}
if (option.fs) {
settings[optionArg] = plugins.path.resolve(settings[optionArg]);
}
}
};
/**
* check mandatories params and paths
* @method setup.checkPaths
* @param {object} settings
*/
export const setupCheckPaths = async (settings) => {
const exists = [];
for (const optionArg of Object.keys(settingsReference)) {
const option = settingsReference[optionArg];
if (option.fs) {
exists.push((async () => {
const exists2 = await plugins.fs.pathExists(settings[optionArg]);
if (!exists2) {
throw Error(`path ${settings[optionArg]} (${optionArg}) does not exists`);
}
})());
}
}
await Promise.all(exists);
};
/**
* merge settings with templates
* create scripts contents
* @method setup.parse
* @param {object} settings
*/
export const setupParse = (settings) => {
if (settings.env) {
settings.envs = '';
for (const key of Object.keys(settings.env)) {
settings.envs += 'Environment=' + key + '=' + settings.env[key] + '\n';
}
}
settings.user = settings.user
? `User=${settings.user}`
: '';
settings.group = settings.group
? `Group=${settings.group}`
: '';
settings.date = (new Date()).toString();
for (const key in settings) {
if (typeof settings[key] === 'string') {
settings[key] = plugins.string.template(settings[key], settings, true);
}
}
const _service = plugins.string.template(templateReference.engines[settings.engine].service, settings, true);
const _start = plugins.string.template(templateReference.engines[settings.engine].start, settings, true);
const _stop = plugins.string.template(templateReference.engines[settings.engine].stop, settings, true);
const _logrotate = settings.logrotate ? plugins.string.template(templateReference.logrotate, settings, true) : '';
return {
service: _service,
start: _start,
stop: _stop,
logrotate: _logrotate
};
};
/**
* write scripts and run commands to install the service
* @method setup.addScripts
* @param {object} settings
* @param {object} contents scripts contents
* @param {string} contents.start
* @param {string} contents.stop
* @param {string} contents.service
*/
export const setupAddScripts = async (settings, contents) => {
const service = plugins.path.join('/etc/systemd/system', `${settings.name}.service`);
const tasks = [];
if (contents.start) {
tasks.push(() => {
const start = plugins.path.join('/usr/local/bin', `systemd-${settings.name}-start`);
logger.log('info', `service-systemd: write file ${start}`);
return plugins.fs.writeFile(start, contents.start, 'utf8');
});
}
if (contents.stop) {
tasks.push(() => {
const stop = plugins.path.join('/usr/local/bin', `systemd-${settings.name}-stop`);
logger.log('info', `service-systemd: write file ${stop}`);
return plugins.fs.writeFile(stop, contents.stop, {
encoding: 'utf8'
});
});
}
if (contents.start || contents.stop) {
tasks.push(() => {
const cmd = `chmod a+x /usr/local/bin/systemd-${settings.name}*`;
logger.log('info', `service-systemd > ${cmd}`);
return smartshellInstance.exec(cmd);
});
}
tasks.push(() => {
logger.log('info', `service-systemd write file ${service}`);
return plugins.fs.writeFile(service, contents.service, 'utf8');
});
tasks.push(() => {
const cmd = `systemctl enable ${service};systemctl daemon-reload`;
logger.log('info', `service-systemd > ${cmd}`);
return smartshellInstance.exec(cmd);
});
for (const task of tasks) {
await task();
}
};
/**
* ensure dirs for log files
* @method setup.addLog
* @param {object} settings
*/
export const setupAddLog = async (settings) => {
const tasks = [];
let dirLog;
let dirError;
if (settings.log) {
dirLog = plugins.path.dirname(settings.log);
logger.log('info', `service-systemd: ensure dir ${dirLog}`);
tasks.push(plugins.fs.ensureDir(dirLog));
}
if (settings.error) {
dirError = plugins.path.dirname(settings.error);
if (dirError !== dirLog) {
logger.log('info', `service-systemd ensure dir ${dirError}`);
tasks.push(plugins.fs.ensureDir(dirError));
}
}
await Promise.all(tasks);
};
/**
* write logrotate conf script
* @method setup.addLogrotate
* @param {object} settings
* @param {object} contents scripts contents
* @param {string} contents.start
* @param {string} contents.stop
* @param {string} contents.service
*/
export const setupAddLogrotate = async (settings, contents) => {
if (!settings.logrotate) {
return;
}
const file = plugins.path.join('/etc/logrotate.d/', settings.name);
logger.log('info', `service-systemd: write logrotate file ${file}`);
await plugins.fs.writeFile(file, contents.logrotate, 'utf8');
};

View File

@ -1,75 +0,0 @@
export const templateReference = {
engines: {
node: {
service:
'# Generated by service-systemd on {{date}}\n' +
'[Unit]\n' +
'Description={description}\n' +
'Requires=network.target\n' +
'After=network.target\n' +
'\n' +
'[Service]\n' +
'Type=simple\n' +
'ExecStart={engine.bin} {engine.args} {app} {app.args}\n' +
'WorkingDirectory={cwd}\n' +
'Restart=on-failure\n' +
'{envs}\n' +
'LimitNOFILE=infinity\n' +
'LimitCORE=infinity\n' +
'StandardInput=null\n' +
'StandardOutput=syslog\n' +
'StandardError=syslog\n' +
'Restart=always\n' +
'SyslogIdentifier={name}\n' +
'PIDFile={pid}\n' +
'{user}\n' +
'{group}\n' +
'[Install]\n' +
'WantedBy=multi-user.target\n'
},
forever: {
service:
'# Generated by service-systemd on {date}\n' +
'[Unit]\n' +
'Description={description}\n' +
'Requires=network.target\n' +
'After=network.target\n' +
'\n' +
'[Service]\n' +
'Type=forking\n' +
'WorkingDirectory={cwd}\n' +
'{envs}\n' +
'ExecStart=/usr/local/bin/systemd-{name}-start\n' +
'ExecStop=/usr/local/bin/systemd-{name}-stop\n' +
'PIDFile={pid}\n' +
'{user}\n' +
'{group}\n' +
'[Install]\n' +
'WantedBy=multi-user.target\n',
start:
'#!/bin/bash\n' +
'{engine.bin} start ' +
'--pidFile {pid} ' +
'--uid {name} ' +
'--sourceDir {cwd} ' +
'-l {log} ' +
'-e {error} ' +
'--append --minUptime 5000 --spinSleepTime 2000 ' +
'{engine.args} ' +
'{app} {app.args}\n' +
'exit 0',
stop: '#!/bin/bash\n' + '{engine.bin} stop {name}\n' + 'exit 0'
}
},
logrotate:
'{log}\n{error} {\n' +
' {logrotate.frequency}\n' +
' rotate {logrotate.rotate}\n' +
' create\n' +
' missingok\n' +
' notifempty\n' +
' compress\n' +
' sharedscripts\n' +
// ' postrotate\n{restart}\n' +
' endscript\n}'
};