Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtinurme committed Oct 29, 2023
1 parent 481fefd commit 6f721ef
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 279 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body:
attributes:
label: Laravel Version
description: What version of Laravel are you running? Please be as specific as possible
placeholder: 9.0.0
placeholder: 10.0.0
validations:
required: true
- type: dropdown
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/:vendor_name/:package_name/discussions/new?category=q-a
url: https://github.com/ahtinurme/octane-health-check/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/:vendor_name/:package_name/discussions/new?category=ideas
url: https://github.com/ahtinurme/octane-health-check/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/:vendor_name/:package_name/security/policy
url: https://github.com/ahtinurme/octane-health-check/security/policy
about: Learn how to notify us for sensitive bugs
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Changelog

All notable changes to `:package_name` will be documented in this file.
All notable changes to `octane-health-check` will be documented in this file.

## 1.0.0 - 2023-10-29

- initial release
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) :vendor_name <author@domain.com>
Copyright (c) Ahti Nurme <ahti@path.ee>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
63 changes: 13 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,30 @@
# :package_description
# A Laravel Health check to monitor Octane server

[![Latest Version on Packagist](https://img.shields.io/packagist/v/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
<!--delete-->
---
This repo can be used to scaffold a Laravel package. Follow these steps to get started:

1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton.
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files.
3. Have fun creating your package.
4. If you need help creating a package, consider picking up our <a href="https://laravelpackage.training">Laravel Package Training</a> video course.
---
<!--/delete-->
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us
This package contains a [Laravel Health](https://spatie.be/docs/laravel-health) check that monitors your Octane server. It can send you a notification when Octane server is not running.

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/:package_name.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/:package_name)
```php
// typically, in a service provider

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
use Ahtinurme\OctaneCheck;
use Spatie\Health\Facades\Health;

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
Health::checks([
OctaneCheck::new(),
]);
```

## Installation

You can install the package via composer:

```bash
composer require :vendor_slug/:package_slug
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag=":package_slug-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag=":package_slug-config"
```

This is the contents of the published config file:

```php
return [
];
```

Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag=":package_slug-views"
```

## Usage

```php
$variable = new VendorName\Skeleton();
echo $variable->echoPhrase('Hello, VendorName!');
composer require ahtinurme/octane-health-check
```

## Testing
Expand All @@ -85,7 +47,8 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [:author_name](https://github.com/:author_username)
- [Amir Sobhani](https://github.com/amirsobhani) - huge thanks for the initial code
- [Ahti Nurme](https://github.com/ahtinurme)
- [All Contributors](../../contributors)

## License
Expand Down
53 changes: 18 additions & 35 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
{
"name": ":vendor_slug/:package_slug",
"description": ":package_description",
"name": "ahtinurme/octane-health-check",
"description": "A Laravel Health check to monitor Octane server",
"keywords": [
":vendor_name",
"ahtinurme",
"laravel",
":package_slug"
"octane-health-check"
],
"homepage": "https://github.com/:vendor_slug/:package_slug",
"homepage": "https://github.com/ahtinurme/octane-health-check",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": "author@domain.com",
"name": "Ahti Nurme",
"email": "ahti@path.ee",
"role": "Developer"
},
{
"name": "Amir Sobhani",
"email": "unknown@email.com",
"role": "Original author"
}
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"illuminate/contracts": "^10.0",
"laravel/octane": "^2.1",
"spatie/laravel-health": "^1.23",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand All @@ -35,29 +42,15 @@
},
"autoload": {
"psr-4": {
"VendorName\\Skeleton\\": "src/",
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
"Ahtinurme\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"VendorName\\Skeleton\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/"
"Ahtinurme\\Tests\\": "tests"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
"@php vendor/bin/testbench workbench:build --ansi"
],
"start": [
"Composer\\Config::disableProcessTimeout",
"@composer run build",
"@php vendor/bin/testbench serve"
],
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
Expand All @@ -70,16 +63,6 @@
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"VendorName\\Skeleton\\SkeletonServiceProvider"
],
"aliases": {
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
6 changes: 0 additions & 6 deletions config/skeleton.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/migrations/create_skeleton_table.php.stub

This file was deleted.

2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ parameters:
level: 4
paths:
- src
- config
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
Expand Down
Empty file removed resources/views/.gitkeep
Empty file.
19 changes: 0 additions & 19 deletions src/Commands/SkeletonCommand.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/Facades/Skeleton.php

This file was deleted.

71 changes: 71 additions & 0 deletions src/OctaneCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Ahtinurme;

use Laravel\Octane\RoadRunner\ServerProcessInspector as RoadRunnerServerProcessInspector;
use Laravel\Octane\Swoole\ServerProcessInspector as SwooleServerProcessInspector;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

class OctaneCheck extends Check
{
protected string $server = 'swoole';

protected ?string $name = 'Octane';

public function run(): Result
{
$result = Result::make();

try {
$server = $this->server ?: config('octane.server');

$isRunning = match ($server) {
'swoole' => $this->isSwooleServerRunning(),
'roadrunner' => $this->isRoadRunnerServerRunning(),
default => $this->invalidServer($result, $server),
};
} catch (\Exception) {
return $result->failed('Octane does not seem to be installed correctly.');
}

if (! $isRunning) {
return $result
->failed('Octane server is not running')
->shortSummary('Not running');
}

return $result
->ok()
->shortSummary('Octane server is running');
}

public function setServer(string $server): static
{
$this->server = $server;

return $this;
}

protected function isSwooleServerRunning(): bool
{
return app(SwooleServerProcessInspector::class)
->serverIsRunning();
}

/**
* Check if the RoadRunner server is running.
*/
protected function isRoadRunnerServerRunning(): bool
{
return app(RoadRunnerServerProcessInspector::class)
->serverIsRunning();
}

protected function invalidServer(Result $result, string $server): Result
{
return $result
->failed('Octane server is not valid')
->shortSummary('Not valid');
}
}
7 changes: 0 additions & 7 deletions src/Skeleton.php

This file was deleted.

Loading

0 comments on commit 6f721ef

Please sign in to comment.