alist 中文文档 下载 App

开机自启配置systemd nssm与vbs脚本

文件站的价值在于「一直在线」,开机自启是标配。

Linux:systemd

写 /usr/lib/systemd/system/alist.service(path_alist 换成程序所在路径):

[Unit]
Description=alist
After=network.target

[Service]
Type=simple
WorkingDirectory=path_alist
ExecStart=path_alist/alist server
Restart=on-failure

[Install]
WantedBy=multi-user.target

然后 systemctl daemon-reload 重载,systemctl enable alist 设自启。之后 start/stop/status/restart 四件套照常。

Windows:两条路

路一:NSSM 注册系统服务

  1. 下载 NSSM;
  2. 在其目录打开 PowerShell,执行 .\nssm.exe install alist;
  3. Path 填 alist.exe 完整路径,Arguments 填 server;
  4. 在 I/O 选项卡为 stdout/stderr 各指定一个日志文件(目录必须存在);
  5. 点 Install Service,以后在系统服务里启停。

路二:VBS 脚本(免装工具)

「启动.vbs」内容:

Dim ws
Set ws = Wscript.CreateObject("Wscript.Shell")
ws.run "alist.exe server",vbhide
Wscript.quit

「停止.vbs」内容:

Dim ws
Set ws = Wscript.CreateObject("Wscript.Shell")
ws.run "taskkill /f /im alist.exe",0
Wscript.quit

两个脚本放在和程序同级目录,双击启动/停止;配合把启动脚本快捷方式放进 shell:startup 文件夹即可开机自启。一键脚本安装的用户不用折腾——管理面板注册服务时自动做了这件事。

macOS:LaunchAgents

编辑 ~/Library/LaunchAgents/ci.nn.alist.plist,KeepAlive 设 true、ProgramArguments 指向程序加 server 参数,然后 launchctl load 加载,start/stop 用 launchctl 控制。

自带管理命令

v3.4.0 起各平台都可用 alist start / stop / restart 做静默启停(依赖程序自身 pid 文件),轻量场景不用配守护进程。