|
1 | | -# Reimplement Yarn Start Command |
2 | | - |
3 | | -## Proposal |
4 | | - |
5 | | -The buildpack will no longer call `yarn start` directly, but instead will |
6 | | -reimplement the behavior of `yarn start` directly. |
7 | | - |
8 | | -## Motivation |
9 | | - |
10 | | -We've seen flakey issues with process signal handling once we implemented [RFC |
11 | | -0001](0001-start-command.md). Specifically, on some container managers, it |
12 | | -appears that `tini` is not waiting for the entire process group to exit before |
13 | | -exiting itself. This means that our tests that make assertions that log lines |
14 | | -appear in the output during process shutdown are unreliable. |
15 | | - |
16 | | -Furthermore, the maintainers of the `yarn` CLI have [openly |
17 | | -stated](https://github.com/yarnpkg/yarn/issues/4667#issuecomment-628241114) |
18 | | -that this issue is considered resolved if you upgrade to `yarn` v2, which the |
19 | | -buildpack has not. There is currently no backport of this functionality to v1 |
20 | | -and may never be. |
21 | | - |
22 | | -Given all of this, it seems to make more sense now to just take on the cost of |
23 | | -reimplementing the behavior of `yarn start` and removing the complexity of |
24 | | -using `yarn` and `tini` together. |
25 | | - |
26 | | -## Implementation |
27 | | - |
28 | | -The buildpack will still require `node` and `node_modules` during the `launch` |
29 | | -phase, but will no longer need to require `yarn` or `tini`. |
30 | | - |
31 | | -Detection will continue to pass once a `yarn.lock` file is present in the app's |
32 | | -source code, assuming all other buildplan requirements have been met. |
33 | | - |
34 | | -If detection is passed, the buildpack will set a start command, optionally also |
35 | | -running the prestart and poststart commands using using the contents of the |
36 | | -`package.json` as follows: |
37 | | - |
38 | | -* If `package.json` contains `scripts.start`, `scripts.prestart`, and |
39 | | - `scripts.poststart` fields, the start command will be `<prestart command> && |
40 | | - <start command> && <poststart command>`. For example, given the following |
41 | | - `package.json`, |
42 | | - |
43 | | - ```json |
44 | | - { |
45 | | - "scripts": { |
46 | | - "poststart": "echo 'Done starting'", |
47 | | - "prestart": "echo 'Starting'", |
48 | | - "start": "node index.js" |
49 | | - } |
50 | | - } |
51 | | - ``` |
52 | | - |
53 | | - The start command will be `echo 'Starting' && node index.js && echo 'Done starting'`. |
54 | | - |
55 | | -* If `package.json` contains `scripts.start` and `scripts.prestart` fields, but |
56 | | - does not contain a `scripts.poststart` field, the start command will be |
57 | | - `<prestart command> && <start command>`. For example, given the following |
58 | | - `package.json`, |
59 | | - |
60 | | - ```json |
61 | | - { |
62 | | - "scripts": { |
63 | | - "prestart": "echo 'Starting'", |
64 | | - "start": "node index.js" |
65 | | - } |
66 | | - } |
67 | | - ``` |
68 | | - |
69 | | - The start command will be `echo 'Starting' && node index.js`. |
70 | | - |
71 | | -* If `package.json` contains `scripts.start` and `scripts.poststart` fields, |
72 | | - but does not contain a `scripts.prestart` field, the start command will be |
73 | | - `<start command> && <poststart command>`. For example, given the following |
74 | | - `package.json`, |
75 | | - |
76 | | - ```json |
77 | | - { |
78 | | - "scripts": { |
79 | | - "poststart": "echo 'Done starting'", |
80 | | - "start": "node index.js" |
81 | | - } |
82 | | - } |
83 | | - ``` |
84 | | - |
85 | | - The start command will be `node index.js && echo 'Done starting'`. |
86 | | - |
87 | | -* If `package.json` contains a `scripts.start`, but does not contain either a |
88 | | - `scripts.prestart` or `scripts.poststart` field, the start command will be |
89 | | - `<start command>`. For example, given the following `package.json`, |
90 | | - |
91 | | - ```json |
92 | | - { |
93 | | - "scripts": { |
94 | | - "start": "node index.js" |
95 | | - } |
96 | | - } |
97 | | - ``` |
98 | | - |
99 | | - The start command will be `node index.js`. |
100 | | - |
101 | | -* If `package.json` does not contain `scripts.start`, `scripts.prestart`, or |
102 | | - `scripts.poststart` fields, the start command will be `node server.js`. For |
103 | | - example, given the following `package.json`, |
104 | | - |
105 | | - ```json |
106 | | - {} |
107 | | - ``` |
108 | | - |
109 | | - The start command will be `node server.js`. |
| 1 | +This page has moved. The new location is: |
| 2 | +https://github.com/paketo-buildpacks/rfcs/blob/main/text/nodejs/0012-reimplement-yarn-start-command.md |
0 commit comments