added deploy button
This commit is contained in:
parent
b6393a7bbf
commit
4b5c74c744
3 changed files with 41 additions and 7 deletions
|
|
@ -14,9 +14,6 @@ primary_region = 'sea'
|
|||
IMAGE_REF="registry.fly.io/snake-api-template:latest"
|
||||
FLY_API_BASE_URL = "https://api.machines.dev/v1"
|
||||
|
||||
[services]
|
||||
internal_only = true
|
||||
|
||||
[http_service]
|
||||
internal_port = 3006
|
||||
force_https = true
|
||||
|
|
|
|||
|
|
@ -230,6 +230,28 @@ app.post("/:appName/upload", async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
// restart a Fly app
|
||||
app.post("/:appName/restart", async (req, res) => {
|
||||
const { appName } = req.params;
|
||||
try {
|
||||
const fly = createFlyClient();
|
||||
const { data: machines } = await fly.get(`/apps/${appName}/machines`);
|
||||
if (!machines || !Array.isArray(machines) || machines.length === 0) {
|
||||
return res.status(404).json({ error: "No machines found for this app" });
|
||||
}
|
||||
const results = await Promise.all(
|
||||
machines.map(machine =>
|
||||
fly.post(`/apps/${appName}/machines/${machine.id}/restart`)
|
||||
)
|
||||
);
|
||||
res.json({ status: "restarted", app: appName, count: results.length });
|
||||
} catch (err) {
|
||||
console.error("Restart error:", err.response?.data || err.message);
|
||||
res.status(500).json({ error: err.response?.data || err.message });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Delete a Fly app
|
||||
app.post("/:appName/delete", async (req, res) => {
|
||||
const { appName } = req.params;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue