Wie stoppe ich die Node.js-Anwendung, die das Forever-Modul unter Windows verwendet?
Lesezeit: 6 Minuten
Satyendra Fauzdar
Ich habe so viele Fragen zum Forever-Modul für nodejs APP durchgegangen, aber keine Antwort gefunden.
Forever Das Modul funktioniert gut auf einer Linux-Box, aber jetzt setze ich meine APP auf Windows 7 und versuche, sie für immer auszuführen. Zuerst habe ich das Forever-Modul als installiert
npm install forever -g
Danach habe ich meine App als ausgeführt
forever start app.js
Es läuft gut, wenn ich sage, dass die Datei app.js für immer ausgeführt wird und ich erfolgreich auf meine App zugreife.
Wenn ich einen Befehl ausführe forever stop app.js Ich bekomme den Fehler
es läuft keine Datei für immer
Bitte schlagen Sie mir vor, wenn jemand Windows für immer verwendet hat, wie ich meine Anwendung unter Windows stoppen kann.
Ich schlage vor, Ihre Node.js-App als Dienst auszuführen. Kasse nssm.cc. Hierfür gibt es auch NPM-Pakete.
– Brad
6. August 2013 um 19:57 Uhr
Versuchen forever stopall Befehl, es könnte funktionieren
– Silpa
29. Juli 2016 um 2:09 Uhr
Laktak
verwenden forever list
dann für immer aufhören mit der id, zB forever stop 0
Hier 0 ist wie ein Index, der in der ersten Spalte der Ausgabe steht. Wenn zwei Prozesse laufen, können wir Indizes wie verwenden 0 oder 1 um den ersten oder den zweiten Prozess zu stoppen.
forever stop 0 ODER forever stop 1
Ich hatte das gleiche Problem und stellte fest, dass es daran lag, dass ich für immer mit sudo (unter Linux) starte, damit ich eine Produktionssite auf Port 80 ausführen konnte. Dies hat den Zweck erfüllt:
sudo forever list
delliottg
Dies dient nur zur Erweiterung der Antwort von @laktak. Das Ergebnis von forever list unter Windows sieht in etwa so aus:
info: Forever processes running
data: uid command script forever p
id id logfile uptime
data: [0] an1b "C:\nodejs\node.exe" C:\sbSerialWidget\server.js 8780 1
0152 C:\Users\username\.forever\an1b.log STOPPED
Ich war mir anfangs nicht sicher, welches die ID war, aber ich fand heraus, dass es der erste Eintrag nach dem zweiten war data Feld oben, also ist die Zeile, an der Sie interessiert sind, mit der ID fett und kursiv gedruckt:
Um diese bestimmte Instanz zu stoppen, würden Sie Folgendes ausführen:
forever stop 0
Hoffe, das hilft jemand anderem, der so verwirrt war wie ich
Ja, das war verwirrend. Das Dokument sagt, Sie können mit ID, PID, Skript aufhören, aber nur mit dem [0] scheint zu funktionieren
– SpeedOfRound
11. Februar 2019 um 18:13 Uhr
Ilja Zaytsev
Es ist ein Fehler in Windows https://github.com/nodejitsu/forever/issues/337
Wenn Sie Ihre App stoppen müssen, öffnen Sie einfach den Task-Manager und suchen Sie den node.js-Prozess und beenden Sie ihn. Schwer, aber Arbeit.
für immer stopp 0
wobei die 0 der Index Ihrer laufenden App ist, wenn Sie nur eine haben, ist dies auch 0.
Ankit Kumar Rajpoot
Sie können den Forever-Dokumenten folgen, dort sind alle Befehle, die sich auf Forever beziehen.
$ forever --help
usage: forever [action] [options] SCRIPT [script-options]
Monitors the script specified in the current process or as a daemon
actions:
start Start SCRIPT as a daemon
stop Stop the daemon SCRIPT by Id|Uid|Pid|Index|Script
stopall Stop all running forever scripts
restart Restart the daemon SCRIPT
restartall Restart all running forever scripts
list List all running forever scripts
config Lists all forever user configuration
set <key> <val> Sets the specified forever config <key>
clear <key> Clears the specified forever config <key>
logs Lists log files for all forever processes
logs <script|index> Tails the logs for <script|index>
columns add <col> Adds the specified column to the output in `forever list`. Supported columns: 'uid', 'command', 'script', 'forever', 'pid', 'id', 'logfile', 'uptime'
columns rm <col> Removed the specified column from the output in `forever list`
columns set <cols> Set all columns for the output in `forever list`
cleanlogs [CAREFUL] Deletes all historical forever log files
options:
-m MAX Only run the specified script MAX times
-l LOGFILE Logs the forever output to LOGFILE
-o OUTFILE Logs stdout from child script to OUTFILE
-e ERRFILE Logs stderr from child script to ERRFILE
-p PATH Base path for all forever related files (pid files, etc.)
-c COMMAND COMMAND to execute (defaults to node)
-a, --append Append logs
-f, --fifo Stream logs to stdout
-n, --number Number of log lines to print
--pidFile The pid file
--uid DEPRECATED. Process uid, useful as a namespace for processes (must wrap in a string)
e.g. forever start --uid "production" app.js
forever stop production
--id DEPRECATED. Process id, similar to uid, useful as a namespace for processes (must wrap in a string)
e.g. forever start --id "test" app.js
forever stop test
--sourceDir The source directory for which SCRIPT is relative to
--workingDir The working directory in which SCRIPT will execute
--minUptime Minimum uptime (millis) for a script to not be considered "spinning"
--spinSleepTime Time to wait (millis) between launches of a spinning script.
--colors --no-colors will disable output coloring
--plain Disable command line colors
-d, --debug Forces forever to log debug output
-v, --verbose Turns on the verbose messages from Forever
-s, --silent Run the child script silencing stdout and stderr
-w, --watch Watch for file changes
--watchDirectory Top-level directory to watch from
--watchIgnore To ignore pattern when watch is enabled (multiple option is allowed)
-t, --killTree Kills the entire child process tree on `stop`
--killSignal Support exit signal customization (default is SIGKILL),
used for restarting script gracefully e.g. --killSignal=SIGTERM
Any console output generated after calling `forever stop/stopall` will not appear in the logs
-h, --help You're staring at it
[Long Running Process]
The forever process will continue to run outputting log messages to the console.
ex. forever -o out.log -e err.log my-script.js
[Daemon]
The forever process will run as a daemon which will make the target process start
in the background. This is extremely useful for remote starting simple node.js scripts
without using nohup. It is recommended to run start with -o -l, & -e.
ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
forever stop my-daemon.js
14038000cookie-checkWie stoppe ich die Node.js-Anwendung, die das Forever-Modul unter Windows verwendet?yes
Ich schlage vor, Ihre Node.js-App als Dienst auszuführen. Kasse nssm.cc. Hierfür gibt es auch NPM-Pakete.
– Brad
6. August 2013 um 19:57 Uhr
Versuchen
forever stopall
Befehl, es könnte funktionieren– Silpa
29. Juli 2016 um 2:09 Uhr