Flood: Init script for a service ?

Created on 24 Oct 2016  ·  7Comments  ·  Source: Flood-UI/flood

Hello,

I see you are recommending to use screen to run flood. However, wouldn't it be more "clean" and practical to start/stop flood with a service ?

I tried to make one without success, and forever does not work either.

wontfix

Most helpful comment

From my side I'm using the following setting:

[Service]
WorkingDirectory=/srv/torrent/flood
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=notell
User=flood
Group=flood
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

It works well (for the moment)

All 7 comments

I tried this :

[Unit]
Description=Flood
After=network.target

[Service]
User=flood
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S flood npm run start:production
ExecStop=/usr/bin/killall -w -s 2 npm
WorkingDirectory=/srv/seedbox/flood

[Install]
WantedBy=default.target

But it does not fish starting. Gulp seems to be executed though
And ExecStop will kill all npm process, which is a bit brutal ^^

Same problem with

[Unit]
Description=Flood
After=network.target

[Service]
User=flood
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S flood ./node_modules/.bin/gulp dist ; ./server/bin/www
ExecStop=/usr/bin/killall -w -s 2 npm
WorkingDirectory=/srv/seedbox/flood

[Install]
WantedBy=default.target

or

[Unit]
Description=Flood
After=network.target

[Service]
User=flood
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S flood ./node_modules/.bin/gulp dist && ./server/bin/www
ExecStop=/usr/bin/killall -w -s 2 npm
WorkingDirectory=/srv/seedbox/flood

[Install]
WantedBy=default.target

only gulp seems to be working

Not working either with

[Unit]
Description=flood
After=network.target

[Service]
Type=simple
# Edit WorkingDirectory, User and Group as needed
WorkingDirectory=/srv/seedbox/flood
User=flood
Group=flood
ExecStart=/usr/bin/npm npm run start:production
ExecStop=/usr/bin/npm stop --production
Restart=always
SyslogIdentifier=Flood

[Install]
WantedBy=multi-user.target
root@hydra ~# systemctl status flood
● flood.service - flood
   Loaded: loaded (/etc/systemd/system/flood.service; disabled)
   Active: active (running) since Wed 2016-10-26 14:08:28 CEST; 2h 2min ago
 Main PID: 621 (npm)
   CGroup: /system.slice/flood.service
           ├─621 npm
           ├─841 sh -c nodemon ./server/bin/www
           └─842 node /srv/seedbox/flood/node_modules/.bin/nodemon ./server/bin/www

Oct 26 14:09:13 hydra Flood[621]: [nodemon] 1.11.0
Oct 26 14:09:13 hydra Flood[621]: [nodemon] to restart at any time, enter `rs`
Oct 26 14:09:13 hydra Flood[621]: [nodemon] watching: *.*
Oct 26 14:09:13 hydra Flood[621]: [nodemon] starting `node ./server/bin/www`
Oct 26 14:09:14 hydra Flood[621]: /srv/seedbox/flood/node_modules/nedb/lib/datastore.js:77
Oct 26 14:09:14 hydra Flood[621]: if (err) { throw err; }
Oct 26 14:09:14 hydra Flood[621]: ^
Oct 26 14:09:14 hydra Flood[621]: Error: EACCES: permission denied, open './server/db/history/yearSnapshot.db'
Oct 26 14:09:14 hydra Flood[621]: at Error (native)
Oct 26 14:09:14 hydra Flood[621]: [nodemon] app crashed - waiting for file changes before starting...

A init script would indeed be nice !

I'd gladly accept a PR for an update to the readme if you can get it working!

Another solution : using https://github.com/Unitech/PM2

From my side I'm using the following setting:

[Service]
WorkingDirectory=/srv/torrent/flood
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=notell
User=flood
Group=flood
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

It works well (for the moment)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EternalBlack picture EternalBlack  ·  6Comments

noeuse picture noeuse  ·  5Comments

rarescosma picture rarescosma  ·  3Comments

geopsllc picture geopsllc  ·  5Comments

noraj picture noraj  ·  4Comments