npm run build的时间较长,因此在配置中额外设置了TimeoutStartSec,延长了等待时间。若未设置这一字段,Systemd将采用在/etc/systemd/system.conf中定义的DefaultTimeoutStartSec=90s。采用默认值可能使得npm run build来不及完成。
启动成功后,输入systemctl status service-pattern-frontend.service
(base) cbs@ubuntu:/$ systemctl status service-pattern-frontend.service ● service-pattern-frontend.service - Service Pattern System Frontend Loaded: loaded (/etc/systemd/system/service-pattern-frontend.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-02-26 01:26:48 CST; 14h ago Process: 26222 ExecStartPre=/usr/local/bin/npm run build (code=exited, status=0/SUCCESS) Main PID: 26422 (node) Tasks: 11 (limit: 4915) CGroup: /system.slice/service-pattern-frontend.service └─26422 node /home/cbs/.yarn/bin/serve -s build -l 6052
Feb 26 01:26:48 ubuntu npm[26222]: You can also analyze the project dependencies: https://goo.gl/LeUzfb Feb 26 01:26:48 ubuntu npm[26222]: The project was built assuming it is hosted at /. Feb 26 01:26:48 ubuntu npm[26222]: You can control this with the homepage field in your package.json. Feb 26 01:26:48 ubuntu npm[26222]: The build folder is ready to be deployed. Feb 26 01:26:48 ubuntu npm[26222]: You may serve it with a static server: Feb 26 01:26:48 ubuntu npm[26222]: serve -s build Feb 26 01:26:48 ubuntu npm[26222]: Find out more about deployment here: Feb 26 01:26:48 ubuntu npm[26222]: bit.ly/CRA-deploy Feb 26 01:26:48 ubuntu systemd[1]: Started Service Pattern System Frontend. Feb 26 01:26:48 ubuntu serve[26422]: INFO: Accepting connections at http://localhost:6052
(base) cbs@ubuntu:/$ journalctl -f -u service-pattern-frontend.service -- Logs begin at Fri 2020-07-31 12:30:45 CST. -- Feb 26 01:26:48 ubuntu npm[26222]: You can also analyze the project dependencies: https://goo.gl/LeUzfb Feb 26 01:26:48 ubuntu npm[26222]: The project was built assuming it is hosted at /. Feb 26 01:26:48 ubuntu npm[26222]: You can control this with the homepage field in your package.json. Feb 26 01:26:48 ubuntu npm[26222]: The build folder is ready to be deployed. Feb 26 01:26:48 ubuntu npm[26222]: You may serve it with a static server: Feb 26 01:26:48 ubuntu npm[26222]: serve -s build Feb 26 01:26:48 ubuntu npm[26222]: Find out more about deployment here: Feb 26 01:26:48 ubuntu npm[26222]: bit.ly/CRA-deploy Feb 26 01:26:48 ubuntu systemd[1]: Started Service Pattern System Frontend. Feb 26 01:26:48 ubuntu serve[26422]: INFO: Accepting connections at http://localhost:6052