diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-03 15:08:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-03 15:08:36 +0200 |
commit | c795e19663a93c24908a7318975f820bac63164f (patch) | |
tree | 149a303be38eedf5aa5a0ec02938f67c75a267fe /server/models/application | |
parent | fd59208e8ccd796f9ad7e35db82d0c33acfcb92c (diff) | |
download | PeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.gz PeerTube-c795e19663a93c24908a7318975f820bac63164f.tar.zst PeerTube-c795e19663a93c24908a7318975f820bac63164f.zip |
Automatically rebuild native modules on ABI change
Diffstat (limited to 'server/models/application')
-rw-r--r-- | server/models/application/application.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/models/application/application.ts b/server/models/application/application.ts index a479de5d2..d4590e001 100644 --- a/server/models/application/application.ts +++ b/server/models/application/application.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import memoizee from 'memoizee' | 1 | import memoizee from 'memoizee' |
2 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' | 2 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' |
3 | import { getNodeABIVersion } from '@server/helpers/version' | ||
3 | import { AttributesOnly } from '@shared/typescript-utils' | 4 | import { AttributesOnly } from '@shared/typescript-utils' |
4 | import { AccountModel } from '../account/account' | 5 | import { AccountModel } from '../account/account' |
5 | 6 | ||
@@ -37,6 +38,14 @@ export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationMo | |||
37 | @Column | 38 | @Column |
38 | latestPeerTubeVersion: string | 39 | latestPeerTubeVersion: string |
39 | 40 | ||
41 | @AllowNull(false) | ||
42 | @Column | ||
43 | nodeVersion: string | ||
44 | |||
45 | @AllowNull(false) | ||
46 | @Column | ||
47 | nodeABIVersion: number | ||
48 | |||
40 | @HasOne(() => AccountModel, { | 49 | @HasOne(() => AccountModel, { |
41 | foreignKey: { | 50 | foreignKey: { |
42 | allowNull: true | 51 | allowNull: true |
@@ -52,4 +61,17 @@ export class ApplicationModel extends Model<Partial<AttributesOnly<ApplicationMo | |||
52 | static load () { | 61 | static load () { |
53 | return ApplicationModel.findOne() | 62 | return ApplicationModel.findOne() |
54 | } | 63 | } |
64 | |||
65 | static async nodeABIChanged () { | ||
66 | const application = await this.load() | ||
67 | |||
68 | return application.nodeABIVersion !== getNodeABIVersion() | ||
69 | } | ||
70 | |||
71 | static async updateNodeVersions () { | ||
72 | const application = await this.load() | ||
73 | |||
74 | application.nodeABIVersion = getNodeABIVersion() | ||
75 | application.nodeVersion = process.version | ||
76 | } | ||
55 | } | 77 | } |