misc/class
lib/jquery_pnotify, lib/moment, lib/lodash, misc/notification, site/engine, misc/social
if( $.browser.msie && $.browser.version <= 8 ) include('lib/respond'); $._social.__cfg = {"init":[{"service":"basic"},{"fb_app_id":"1997094873850041","service":"fb"},{"vk_app_id":"2978320","service":"vk"},{"service":"twi"}],"like":[{"service":"fb"},{"service":"vk"},{"via":"","channel":"","hash_tag":"","service":"twi"}]}; window._SiteEngine = new classes.SiteEngine( { user_id: 0, controller: 'content_article', action: 'view', content_css_version: '1459538664', social_enabled: 0} );

Faiwer

Блог web-программиста

How to make a simple system.d service for a node.js server

Put this content:

[Unit]
Description={name}

[Service]
Type=simple
User={user}
ExecStart=/usr/bin/node {full-path-to-script}.js

[Install]
WantedBy=multi-user.target

... somewhere as {name}.service, where:

  • {name} is the name of the service
  • {user} is the name of the user to run the script (optional)

... then:

  • run: this sudo ln -s /{full_path}/{name}.service /lib/systemd/system/{name}.service 
  • then this: sudo systemctl daemon-reload
  • then this: sudo systemctl enable {name}.service
  • and finally this: sudo systemctl start {name}

How does it work?

  • It starts the service on boot (see WantedBy section).
  • Using ExecStart command. Important: we specify the full path to node
  • SystemD remembers the PID of the new process and considers the service is ongoing until the process is died.
  • So any subsequent systemctrl start {name} won't do anything if the previous process is alive.
  • This behavior is determined by Type=Simple
Теги:
Linux node
Комментарии
Оставить комментарий
Оставить комментарий:
Отправить через:
Предпросмотр
modules/comment
window._Comment_content_article_178 = new classes.Comment( '#comment_block_content_article_178', { type: 'content_article', node_id: '178', user: 1, user_id: 0, admin: 0, view_time: null, msg: { empty: 'Комментарий пуст', ask_link: 'Ссылка:', ask_img: 'Ссылка на изображение:' } });