Spaces:
Paused

Workbro / server.js
ogzayn's picture
Create server.js
07fe048 verified
Raw History Blame Contribute Delete
1.19 kB
const { spawnSync } = require('child_process')
const { existsSync, writeFileSync } = require('fs')
const SESSION_ID = 'levanter_17b679cea1a96748d38a7ff37c165070ac' // Edit this line only, don't remove ' <- this symbol
if (!existsSync('levanter')) {
console.log('Cloning the repository...')
const cloneResult = spawnSync(
'git',
['clone', 'https://github.com/lyfe00011/levanter.git', 'levanter'],
{
stdio: 'inherit',
}
)
if (cloneResult.error) {
throw new Error(`Failed to clone the repository: ${cloneResult.error.message}`)
}
const configPath = 'levanter/config.env'
try {
console.log('Writing to config.env...')
writeFileSync(configPath, `VPS=true\nSESSION_ID=${SESSION_ID}`)
} catch (err) {
throw new Error(`Failed to write to config.env: ${err.message}`)
}
console.log('Installing dependencies...')
const installResult = spawnSync('yarn', ['install', '--network-concurrency', '3'], {
cwd: 'levanter',
stdio: 'inherit',
})
if (installResult.error) {
throw new Error(`Failed to install dependencies: ${installResult.error.message}`)
}
}
spawnSync('yarn', ['start'], { cwd: 'levanter', stdio: 'inherit' })