Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Node.js daemon/service ====== <code powershell Windows> npm install winser npm install -g pkg pkg index.js --output myApp.exe # Use npm_modules/winser/bin/nssm64.exe to create service </code> Make a myapp.service file (replacing 'myapp' with your app's name, obviously): <code bash Linux> [Unit] Description=My app After=network.target [Service] ExecStart=/var/www/myapp/app.js Restart=always User=nobody # Debian/Ubuntu uses 'nogroup' # RHEL/Fedora uses 'nobody' Group=nogroup Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production WorkingDirectory=/var/www/myapp [Install] WantedBy=multi-user.target </code> Note: **/var/www/myapp/app.js** should have **#!/usr/bin/env node** on the very first line Copy your service file into the **/etc/systemd/system** Start it with **systemctl start myapp** Enable it on boot with **systemctl enable myapp** See logs with **journalctl -u myapp** development/js/node_js_service.txt Last modified: 2019/10/31 09:04by 127.0.0.1